Apply aRPPs for replies with a listener container

- `afterReceivePostProcessors` were not applied when using
  a reply container.
This commit is contained in:
Gary Russell
2019-12-11 16:22:09 -05:00
parent 5cadcc3f79
commit 828e6b17e5
3 changed files with 25 additions and 0 deletions

1
.gitignore vendored
View File

@@ -19,3 +19,4 @@ erl_crash.dump
nohup.out
src/ant/.ant-targets-upload-dist.xml
target
.sts4-cache/

View File

@@ -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);

View File

@@ -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();