Skip to content

Commit 3f65fc0

Browse files
PlatonovLexartembilan
authored andcommitted
GH-1087: RabbitTemplate: improvement debug logging
Fixes #1087 Debug information about the sent message was recorded in the log before processing by `MessagePostProcessors`, so the information on the console might not coincide with reality. Added log of the message after processing by `MessagePostProcessor`
1 parent 1a17848 commit 3f65fc0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitTemplate.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
* @author Ernest Sadykov
144144
* @author Mark Norkin
145145
* @author Mohammad Hewedy
146+
* @author Alexey Platonov
146147
*
147148
* @since 1.0
148149
*/
@@ -2290,9 +2291,9 @@ public void doSend(Channel channel, String exchangeArg, String routingKeyArg, Me
22902291
if (rKey == null) {
22912292
rKey = this.routingKey;
22922293
}
2293-
if (logger.isDebugEnabled()) {
2294-
logger.debug("Publishing message " + message
2295-
+ "on exchange [" + exch + "], routingKey = [" + rKey + "]");
2294+
2295+
if (logger.isTraceEnabled()) {
2296+
logger.trace("Original message to publish: " + message);
22962297
}
22972298

22982299
Message messageToUse = message;
@@ -2312,6 +2313,10 @@ public void doSend(Channel channel, String exchangeArg, String routingKeyArg, Me
23122313
messageProperties.setUserId(userId);
23132314
}
23142315
}
2316+
if (logger.isDebugEnabled()) {
2317+
logger.debug("Publishing message [" + messageToUse
2318+
+ "] on exchange [" + exch + "], routingKey = [" + rKey + "]");
2319+
}
23152320
sendToRabbit(channel, exch, rKey, mandatory, messageToUse);
23162321
// Check if commit needed
23172322
if (isChannelLocallyTransacted(channel)) {

0 commit comments

Comments
 (0)