use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class MethodInvokingMessageHandlerTests method subscription.
@Test
public void subscription() throws Exception {
TestApplicationContext context = TestUtils.createTestApplicationContext();
SynchronousQueue<String> queue = new SynchronousQueue<String>();
TestBean testBean = new TestBean(queue);
QueueChannel channel = new QueueChannel();
context.registerChannel("channel", channel);
Message<String> message = new GenericMessage<String>("testing");
channel.send(message);
assertNull(queue.poll());
MethodInvokingMessageHandler handler = new MethodInvokingMessageHandler(testBean, "foo");
PollingConsumer endpoint = new PollingConsumer(channel, handler);
endpoint.setTrigger(new PeriodicTrigger(10));
context.registerEndpoint("testEndpoint", endpoint);
context.refresh();
String result = queue.poll(2000, TimeUnit.MILLISECONDS);
assertNotNull(result);
assertEquals("testing", result);
context.stop();
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class CustomConverterMessageProcessingTests method serviceActivator.
@Test
public void serviceActivator() {
QueueChannel replyChannel = new QueueChannel();
Message<?> message = MessageBuilder.withPayload(new TestBean1("service-test")).setReplyChannel(replyChannel).build();
this.serviceActivatorChannel.send(message);
Message<?> result = replyChannel.receive(0);
assertNotNull(result);
assertNotNull(result.getPayload());
assertEquals(TestBean2.class, result.getPayload().getClass());
assertEquals("SERVICE-TEST", ((TestBean2) result.getPayload()).text);
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class CustomConverterMessageProcessingTests method splitter.
@Test
public void splitter() {
QueueChannel replyChannel = new QueueChannel();
Message<?> message = MessageBuilder.withPayload(new TestBean1("splitter-test")).setReplyChannel(replyChannel).build();
this.splitterChannel.send(message);
Message<?> result = replyChannel.receive(0);
assertNotNull(result);
assertNotNull(result.getPayload());
assertEquals(TestBean2.class, result.getPayload().getClass());
assertEquals("SPLITTER-TEST", ((TestBean2) result.getPayload()).text);
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class CustomConverterMessageProcessingTests method filter.
@Test
public void filter() {
QueueChannel replyChannel = new QueueChannel();
Message<?> message = MessageBuilder.withPayload(new TestBean1("filter-test")).setReplyChannel(replyChannel).build();
this.filterChannel.send(message);
Message<?> result = replyChannel.receive(0);
assertNotNull(result);
assertNotNull(result.getPayload());
assertEquals(TestBean1.class, result.getPayload().getClass());
assertEquals("filter-test", ((TestBean1) result.getPayload()).text);
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class JsonPathTests method testJsonPathOnPayloadAnnotation.
@Test
public void testJsonPathOnPayloadAnnotation() {
QueueChannel replyChannel = new QueueChannel();
Message<String> message = MessageBuilder.withPayload(JSON).setHeader(MessageHeaders.REPLY_CHANNEL, replyChannel).build();
this.jsonPathMessageChannel.send(message);
Message<?> receive = replyChannel.receive(10_000);
assertNotNull(receive);
assertEquals("Nigel Rees", receive.getPayload());
}
Aggregations