20
20
21
21
import org .springframework .lang .Nullable ;
22
22
import org .springframework .messaging .Message ;
23
+ import org .springframework .messaging .MessagingException ;
23
24
import org .springframework .util .Assert ;
24
25
25
26
/**
@@ -65,74 +66,82 @@ public DestinationResolver<D> getDestinationResolver() {
65
66
return this .destinationResolver ;
66
67
}
67
68
69
+ protected final D resolveDestination (String destinationName ) throws DestinationResolutionException {
70
+ Assert .state (this .destinationResolver != null ,
71
+ "DestinationResolver is required to resolve destination names" );
72
+ return this .destinationResolver .resolveDestination (destinationName );
73
+ }
74
+
68
75
69
76
@ Override
70
- public void send (String destinationName , Message <?> message ) {
77
+ public void send (String destinationName , Message <?> message ) throws MessagingException {
71
78
D destination = resolveDestination (destinationName );
72
79
doSend (destination , message );
73
80
}
74
81
75
- protected final D resolveDestination (String destinationName ) {
76
-
77
- Assert .state (this .destinationResolver != null , "DestinationResolver is required to resolve destination names" );
78
- return this .destinationResolver .resolveDestination (destinationName );
79
- }
80
-
81
82
@ Override
82
- public <T > void convertAndSend (String destinationName , T payload ) {
83
+ public <T > void convertAndSend (String destinationName , T payload ) throws MessagingException {
83
84
convertAndSend (destinationName , payload , null , null );
84
85
}
85
86
86
87
@ Override
87
- public <T > void convertAndSend (String destinationName , T payload , @ Nullable Map <String , Object > headers ) {
88
+ public <T > void convertAndSend (String destinationName , T payload , @ Nullable Map <String , Object > headers )
89
+ throws MessagingException {
90
+
88
91
convertAndSend (destinationName , payload , headers , null );
89
92
}
90
93
91
94
@ Override
92
- public <T > void convertAndSend (String destinationName , T payload , @ Nullable MessagePostProcessor postProcessor ) {
95
+ public <T > void convertAndSend (String destinationName , T payload , @ Nullable MessagePostProcessor postProcessor )
96
+ throws MessagingException {
97
+
93
98
convertAndSend (destinationName , payload , null , postProcessor );
94
99
}
95
100
96
101
@ Override
97
- public <T > void convertAndSend (String destinationName , T payload ,
98
- @ Nullable Map < String , Object > headers , @ Nullable MessagePostProcessor postProcessor ) {
102
+ public <T > void convertAndSend (String destinationName , T payload , @ Nullable Map < String , Object > headers ,
103
+ @ Nullable MessagePostProcessor postProcessor ) throws MessagingException {
99
104
100
105
D destination = resolveDestination (destinationName );
101
106
super .convertAndSend (destination , payload , headers , postProcessor );
102
107
}
103
108
104
109
@ Override
105
110
@ Nullable
106
- public Message <?> receive (String destinationName ) {
111
+ public Message <?> receive (String destinationName ) throws MessagingException {
107
112
D destination = resolveDestination (destinationName );
108
113
return super .receive (destination );
109
114
}
110
115
111
116
@ Override
112
117
@ Nullable
113
- public <T > T receiveAndConvert (String destinationName , Class <T > targetClass ) {
118
+ public <T > T receiveAndConvert (String destinationName , Class <T > targetClass ) throws MessagingException {
114
119
D destination = resolveDestination (destinationName );
115
120
return super .receiveAndConvert (destination , targetClass );
116
121
}
117
122
118
123
@ Override
119
124
@ Nullable
120
- public Message <?> sendAndReceive (String destinationName , Message <?> requestMessage ) {
125
+ public Message <?> sendAndReceive (String destinationName , Message <?> requestMessage )
126
+ throws MessagingException {
127
+
121
128
D destination = resolveDestination (destinationName );
122
129
return super .sendAndReceive (destination , requestMessage );
123
130
}
124
131
125
132
@ Override
126
133
@ Nullable
127
- public <T > T convertSendAndReceive (String destinationName , Object request , Class <T > targetClass ) {
134
+ public <T > T convertSendAndReceive (String destinationName , Object request , Class <T > targetClass )
135
+ throws MessagingException {
136
+
128
137
D destination = resolveDestination (destinationName );
129
138
return super .convertSendAndReceive (destination , request , targetClass );
130
139
}
131
140
132
141
@ Override
133
142
@ Nullable
134
143
public <T > T convertSendAndReceive (String destinationName , Object request ,
135
- @ Nullable Map <String , Object > headers , Class <T > targetClass ) {
144
+ @ Nullable Map <String , Object > headers , Class <T > targetClass ) throws MessagingException {
136
145
137
146
D destination = resolveDestination (destinationName );
138
147
return super .convertSendAndReceive (destination , request , headers , targetClass );
@@ -141,7 +150,7 @@ public <T> T convertSendAndReceive(String destinationName, Object request,
141
150
@ Override
142
151
@ Nullable
143
152
public <T > T convertSendAndReceive (String destinationName , Object request , Class <T > targetClass ,
144
- @ Nullable MessagePostProcessor postProcessor ) {
153
+ @ Nullable MessagePostProcessor postProcessor ) throws MessagingException {
145
154
146
155
D destination = resolveDestination (destinationName );
147
156
return super .convertSendAndReceive (destination , request , targetClass , postProcessor );
@@ -151,7 +160,7 @@ public <T> T convertSendAndReceive(String destinationName, Object request, Class
151
160
@ Nullable
152
161
public <T > T convertSendAndReceive (String destinationName , Object request ,
153
162
@ Nullable Map <String , Object > headers , Class <T > targetClass ,
154
- @ Nullable MessagePostProcessor postProcessor ) {
163
+ @ Nullable MessagePostProcessor postProcessor ) throws MessagingException {
155
164
156
165
D destination = resolveDestination (destinationName );
157
166
return super .convertSendAndReceive (destination , request , headers , targetClass , postProcessor );
0 commit comments