3333 * routing key to use.
3434 *
3535 * @author Stephane Nicoll
36+ * @author Artem Bilan
37+ *
3638 * @since 1.4
39+ *
3740 * @see org.springframework.amqp.rabbit.core.RabbitTemplate
3841 */
3942public interface RabbitMessageOperations extends MessageSendingOperations <String >,
@@ -46,7 +49,7 @@ public interface RabbitMessageOperations extends MessageSendingOperations<String
4649 * @param message the message to send
4750 * @throws MessagingException a messaging exception.
4851 */
49- void send (String exchange , String routingKey , Message <?> message ) throws MessagingException ;
52+ void send (@ Nullable String exchange , @ Nullable String routingKey , Message <?> message ) throws MessagingException ;
5053
5154 /**
5255 * Convert the given Object to serialized form, possibly using a
@@ -58,7 +61,11 @@ public interface RabbitMessageOperations extends MessageSendingOperations<String
5861 * @param payload the Object to use as payload
5962 * @throws MessagingException a messaging exception.
6063 */
61- void convertAndSend (String exchange , String routingKey , Object payload ) throws MessagingException ;
64+ default void convertAndSend (@ Nullable String exchange , @ Nullable String routingKey , Object payload )
65+ throws MessagingException {
66+
67+ convertAndSend (exchange , routingKey , payload , null , null );
68+ }
6269
6370 /**
6471 * Convert the given Object to serialized form, possibly using a
@@ -71,8 +78,11 @@ public interface RabbitMessageOperations extends MessageSendingOperations<String
7178 * @param headers headers for the message to send
7279 * @throws MessagingException a messaging exception.
7380 */
74- void convertAndSend (String exchange , String routingKey , Object payload , Map <String , Object > headers )
75- throws MessagingException ;
81+ default void convertAndSend (@ Nullable String exchange , @ Nullable String routingKey , Object payload ,
82+ @ Nullable Map <String , Object > headers ) throws MessagingException {
83+
84+ convertAndSend (exchange , routingKey , payload , headers , null );
85+ }
7686
7787 /**
7888 * Convert the given Object to serialized form, possibly using a
@@ -86,8 +96,11 @@ void convertAndSend(String exchange, String routingKey, Object payload, Map<Stri
8696 * @param postProcessor the post processor to apply to the message
8797 * @throws MessagingException a messaging exception.
8898 */
89- void convertAndSend (String exchange , String routingKey , Object payload , MessagePostProcessor postProcessor )
90- throws MessagingException ;
99+ default void convertAndSend (@ Nullable String exchange , @ Nullable String routingKey , Object payload ,
100+ @ Nullable MessagePostProcessor postProcessor ) throws MessagingException {
101+
102+ convertAndSend (exchange , routingKey , payload , null , postProcessor );
103+ }
91104
92105 /**
93106 * Convert the given Object to serialized form, possibly using a
@@ -102,8 +115,9 @@ void convertAndSend(String exchange, String routingKey, Object payload, MessageP
102115 * @param postProcessor the post processor to apply to the message
103116 * @throws MessagingException a messaging exception.
104117 */
105- void convertAndSend (String exchange , String routingKey , Object payload ,
106- @ Nullable Map <String , Object > headers , @ Nullable MessagePostProcessor postProcessor ) throws MessagingException ;
118+ void convertAndSend (@ Nullable String exchange , @ Nullable String routingKey , Object payload ,
119+ @ Nullable Map <String , Object > headers , @ Nullable MessagePostProcessor postProcessor )
120+ throws MessagingException ;
107121
108122 /**
109123 * Send a request message to a specific exchange with a specific routing key and
@@ -116,7 +130,8 @@ void convertAndSend(String exchange, String routingKey, Object payload,
116130 * @throws MessagingException a messaging exception.
117131 */
118132 @ Nullable
119- Message <?> sendAndReceive (String exchange , String routingKey , Message <?> requestMessage ) throws MessagingException ;
133+ Message <?> sendAndReceive (@ Nullable String exchange , @ Nullable String routingKey , Message <?> requestMessage )
134+ throws MessagingException ;
120135
121136 /**
122137 * Convert the given request Object to serialized form, possibly using a
@@ -132,8 +147,11 @@ void convertAndSend(String exchange, String routingKey, Object payload,
132147 * could not be received, for example due to a timeout
133148 * @throws MessagingException a messaging exception.
134149 */
135- <T > @ Nullable T convertSendAndReceive (String exchange , String routingKey , Object request , Class <T > targetClass )
136- throws MessagingException ;
150+ default <T > @ Nullable T convertSendAndReceive (@ Nullable String exchange , @ Nullable String routingKey ,
151+ Object request , Class <T > targetClass ) throws MessagingException {
152+
153+ return convertSendAndReceive (exchange , routingKey , request , null , targetClass );
154+ }
137155
138156 /**
139157 * Convert the given request Object to serialized form, possibly using a
@@ -151,8 +169,11 @@ void convertAndSend(String exchange, String routingKey, Object payload,
151169 * could not be received, for example due to a timeout
152170 * @throws MessagingException a messaging exception.
153171 */
154- <T > @ Nullable T convertSendAndReceive (String exchange , String routingKey , Object request ,
155- @ Nullable Map <String , Object > headers , Class <T > targetClass ) throws MessagingException ;
172+ default <T > @ Nullable T convertSendAndReceive (@ Nullable String exchange , @ Nullable String routingKey ,
173+ Object request , @ Nullable Map <String , Object > headers , Class <T > targetClass ) throws MessagingException {
174+
175+ return convertSendAndReceive (exchange , routingKey , request , headers , targetClass , null );
176+ }
156177
157178 /**
158179 * Convert the given request Object to serialized form, possibly using a
@@ -170,8 +191,12 @@ void convertAndSend(String exchange, String routingKey, Object payload,
170191 * could not be received, for example due to a timeout
171192 * @throws MessagingException a messaging exception.
172193 */
173- <T > @ Nullable T convertSendAndReceive (String exchange , String routingKey , Object request , Class <T > targetClass ,
174- @ Nullable MessagePostProcessor requestPostProcessor ) throws MessagingException ;
194+ default <T > @ Nullable T convertSendAndReceive (@ Nullable String exchange , @ Nullable String routingKey ,
195+ Object request , Class <T > targetClass , @ Nullable MessagePostProcessor requestPostProcessor )
196+ throws MessagingException {
197+
198+ return convertSendAndReceive (exchange , routingKey , request , null , targetClass , requestPostProcessor );
199+ }
175200
176201 /**
177202 * Convert the given request Object to serialized form, possibly using a
@@ -191,7 +216,7 @@ void convertAndSend(String exchange, String routingKey, Object payload,
191216 * could not be received, for example due to a timeout
192217 * @throws MessagingException a messaging exception.
193218 */
194- <T > @ Nullable T convertSendAndReceive (String exchange , String routingKey , Object request ,
219+ <T > @ Nullable T convertSendAndReceive (@ Nullable String exchange , @ Nullable String routingKey , Object request ,
195220 @ Nullable Map <String , Object > headers , Class <T > targetClass ,
196221 @ Nullable MessagePostProcessor requestPostProcessor ) throws MessagingException ;
197222
0 commit comments