MessageChannel requestChannel = applicationContext.getBean("channelD", MessageChannel.class);
DirectChannel responseChannel = applicationContext.getBean("channelC", DirectChannel.class);
Map<String, Object> headers = new HashMap<String, Object>();
headers.put(MessageHeaders.REPLY_CHANNEL, responseChannel);
GenericMessage<String> message = new GenericMessage<String>(MESSAGE_BODY, headers);
responseChannel.subscribe(new MessageHandler() {
public void handleMessage(Message<?> message) {
String result = (String) message.getPayload();
assertEquals("Get the wrong result", MESSAGE_BODY + " is processed", result);
}
});