Apply aRPPs for replies with a listener container
- `afterReceivePostProcessors` were not applied when using a reply container.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -19,3 +19,4 @@ erl_crash.dump
|
||||
nohup.out
|
||||
src/ant/.ant-targets-upload-dist.xml
|
||||
target
|
||||
.sts4-cache/
|
||||
|
||||
@@ -1936,6 +1936,11 @@ public class RabbitTemplate extends RabbitAccessor // NOSONAR type line count
|
||||
try {
|
||||
reply = exchangeMessages(exchange, routingKey, message, correlationData, channel, pendingReply,
|
||||
messageTag);
|
||||
if (reply != null && this.afterReceivePostProcessors != null) {
|
||||
for (MessagePostProcessor processor : this.afterReceivePostProcessors) {
|
||||
reply = processor.postProcessMessage(reply);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
this.replyHolder.remove(messageTag);
|
||||
|
||||
@@ -409,6 +409,25 @@ public class EnableRabbitIntegrationTests {
|
||||
assertEquals(reply.getMessageProperties().getHeaders().get("replyMPPApplied"), Boolean.TRUE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void endpointWithHeaderReplyMPP() {
|
||||
MessageProperties properties = new MessageProperties();
|
||||
properties.setHeader("prefix", "prefix-");
|
||||
Message request = MessageTestUtils.createTextMessage("foo", properties);
|
||||
AtomicReference<Message> replyRef = new AtomicReference<>();
|
||||
rabbitTemplate.setAfterReceivePostProcessors(msg -> {
|
||||
replyRef.set(msg);
|
||||
return msg;
|
||||
});
|
||||
rabbitTemplate.convertSendAndReceive("", "test.header", "", msg -> {
|
||||
return request;
|
||||
});
|
||||
Message reply = replyRef.get();
|
||||
assertNotNull(reply);
|
||||
assertEquals("prefix-FOO", MessageTestUtils.extractText(reply));
|
||||
assertEquals(reply.getMessageProperties().getHeaders().get("replyMPPApplied"), Boolean.TRUE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void endpointWithMessage() {
|
||||
MessageProperties properties = new MessageProperties();
|
||||
|
||||
Reference in New Issue
Block a user