Skip to content

Commit

Permalink
Apply aRPPs for replies with a listener container
Browse files Browse the repository at this point in the history
- `afterReceivePostProcessors` were not applied when using
  a reply container.
  • Loading branch information
garyrussell committed Dec 11, 2019
1 parent 5cadcc3 commit 828e6b1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ erl_crash.dump
nohup.out
src/ant/.ant-targets-upload-dist.xml
target
.sts4-cache/
Original file line number Diff line number Diff line change
Expand Up @@ -1936,6 +1936,11 @@ private Message doSendAndReceiveAsListener(final String exchange, final String r
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,25 @@ public void endpointWithHeader() {
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();
Expand Down

0 comments on commit 828e6b1

Please sign in to comment.