Message message = new Message("Hello, world!".getBytes(), messageProperties);
final AtomicReference<String> replyTo = new AtomicReference<String>();
final AtomicReference<String> correlationId = new AtomicReference<String>();
doAnswer(new Answer<Object>() {
public Object answer(InvocationOnMock invocation) throws Throwable {
BasicProperties basicProps = (BasicProperties) invocation.getArguments()[3];
replyTo.set(basicProps.getReplyTo());
if (standardHeader) {
correlationId.set(basicProps.getCorrelationId());
}
else {
correlationId.set((String) basicProps.getHeaders().get(CORRELATION_HEADER));
}
MessageProperties springProps = new DefaultMessagePropertiesConverter()
.toMessageProperties(basicProps, null, "UTF-8");
Message replyMessage = new Message("!dlrow olleH".getBytes(), springProps);
template.onMessage(replyMessage);