use of org.springframework.messaging.support.GenericMessage in project camel by apache.
the class SpringIntegrationTwoWayConsumerTest method testSendingTwoWayMessage.
@Test
public void testSendingTwoWayMessage() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
MessageChannel requestChannel = getMandatoryBean(MessageChannel.class, "requestChannel");
Map<String, Object> maps = new HashMap<String, Object>();
maps.put(MessageHeaders.REPLY_CHANNEL, "responseChannel");
Message<String> message = new GenericMessage<String>(MESSAGE_BODY, maps);
DirectChannel responseChannel = getMandatoryBean(DirectChannel.class, "responseChannel");
responseChannel.subscribe(new MessageHandler() {
public void handleMessage(Message<?> message) {
latch.countDown();
assertEquals("Get the wrong result", MESSAGE_BODY + " is processed", message.getPayload());
assertEquals("Done", message.getHeaders().get("Status"));
}
});
requestChannel.send(message);
assertTrue(latch.await(1, TimeUnit.SECONDS));
}
use of org.springframework.messaging.support.GenericMessage in project camel by apache.
the class CamelTargetAdapterTest method testSendingTwoWayMessage.
@Test
public void testSendingTwoWayMessage() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
MessageChannel requestChannel = getMandatoryBean(MessageChannel.class, "channelB");
Message<?> message = new GenericMessage<Object>(MESSAGE_BODY);
//Need to subscribe the responseChannel first
DirectChannel responseChannel = getMandatoryBean(DirectChannel.class, "channelC");
responseChannel.subscribe(new MessageHandler() {
public void handleMessage(Message<?> message) {
latch.countDown();
assertEquals("Get the wrong result", MESSAGE_BODY + " is processed", message.getPayload());
}
});
requestChannel.send(message);
assertTrue(latch.await(1, TimeUnit.SECONDS));
}
use of org.springframework.messaging.support.GenericMessage in project camel by apache.
the class CamelTargetAdapterTest method testSendingTwoWayMessageWithMessageAddress.
@Test
public void testSendingTwoWayMessageWithMessageAddress() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
MessageChannel requestChannel = getMandatoryBean(MessageChannel.class, "channelD");
DirectChannel responseChannel = getMandatoryBean(DirectChannel.class, "channelC");
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) {
latch.countDown();
assertEquals("Get the wrong result", MESSAGE_BODY + " is processed", message.getPayload());
}
});
requestChannel.send(message);
assertTrue(latch.await(1, TimeUnit.SECONDS));
}
use of org.springframework.messaging.support.GenericMessage in project spring-framework by spring-projects.
the class MessageReceivingTemplateTests method receiveAndConvertFailed.
@Test
public void receiveAndConvertFailed() {
Message<?> expected = new GenericMessage<Object>("not a number test");
this.template.setReceiveMessage(expected);
this.template.setMessageConverter(new GenericMessageConverter());
thrown.expect(MessageConversionException.class);
thrown.expectCause(isA(ConversionFailedException.class));
this.template.receiveAndConvert("somewhere", Integer.class);
}
Aggregations