2020
2121import org .springframework .lang .Nullable ;
2222import org .springframework .messaging .Message ;
23+ import org .springframework .messaging .MessagingException ;
2324import org .springframework .util .Assert ;
2425
2526/**
@@ -65,74 +66,82 @@ public DestinationResolver<D> getDestinationResolver() {
6566 return this .destinationResolver ;
6667 }
6768
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+
6875
6976 @ Override
70- public void send (String destinationName , Message <?> message ) {
77+ public void send (String destinationName , Message <?> message ) throws MessagingException {
7178 D destination = resolveDestination (destinationName );
7279 doSend (destination , message );
7380 }
7481
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-
8182 @ Override
82- public <T > void convertAndSend (String destinationName , T payload ) {
83+ public <T > void convertAndSend (String destinationName , T payload ) throws MessagingException {
8384 convertAndSend (destinationName , payload , null , null );
8485 }
8586
8687 @ 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+
8891 convertAndSend (destinationName , payload , headers , null );
8992 }
9093
9194 @ 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+
9398 convertAndSend (destinationName , payload , null , postProcessor );
9499 }
95100
96101 @ 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 {
99104
100105 D destination = resolveDestination (destinationName );
101106 super .convertAndSend (destination , payload , headers , postProcessor );
102107 }
103108
104109 @ Override
105110 @ Nullable
106- public Message <?> receive (String destinationName ) {
111+ public Message <?> receive (String destinationName ) throws MessagingException {
107112 D destination = resolveDestination (destinationName );
108113 return super .receive (destination );
109114 }
110115
111116 @ Override
112117 @ Nullable
113- public <T > T receiveAndConvert (String destinationName , Class <T > targetClass ) {
118+ public <T > T receiveAndConvert (String destinationName , Class <T > targetClass ) throws MessagingException {
114119 D destination = resolveDestination (destinationName );
115120 return super .receiveAndConvert (destination , targetClass );
116121 }
117122
118123 @ Override
119124 @ Nullable
120- public Message <?> sendAndReceive (String destinationName , Message <?> requestMessage ) {
125+ public Message <?> sendAndReceive (String destinationName , Message <?> requestMessage )
126+ throws MessagingException {
127+
121128 D destination = resolveDestination (destinationName );
122129 return super .sendAndReceive (destination , requestMessage );
123130 }
124131
125132 @ Override
126133 @ 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+
128137 D destination = resolveDestination (destinationName );
129138 return super .convertSendAndReceive (destination , request , targetClass );
130139 }
131140
132141 @ Override
133142 @ Nullable
134143 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 {
136145
137146 D destination = resolveDestination (destinationName );
138147 return super .convertSendAndReceive (destination , request , headers , targetClass );
@@ -141,7 +150,7 @@ public <T> T convertSendAndReceive(String destinationName, Object request,
141150 @ Override
142151 @ Nullable
143152 public <T > T convertSendAndReceive (String destinationName , Object request , Class <T > targetClass ,
144- @ Nullable MessagePostProcessor postProcessor ) {
153+ @ Nullable MessagePostProcessor postProcessor ) throws MessagingException {
145154
146155 D destination = resolveDestination (destinationName );
147156 return super .convertSendAndReceive (destination , request , targetClass , postProcessor );
@@ -151,7 +160,7 @@ public <T> T convertSendAndReceive(String destinationName, Object request, Class
151160 @ Nullable
152161 public <T > T convertSendAndReceive (String destinationName , Object request ,
153162 @ Nullable Map <String , Object > headers , Class <T > targetClass ,
154- @ Nullable MessagePostProcessor postProcessor ) {
163+ @ Nullable MessagePostProcessor postProcessor ) throws MessagingException {
155164
156165 D destination = resolveDestination (destinationName );
157166 return super .convertSendAndReceive (destination , request , headers , targetClass , postProcessor );
0 commit comments