use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class AsyncMessagingTemplateTests method asyncReceiveAndConvertWithDefaultChannel.
@Test
public void asyncReceiveAndConvertWithDefaultChannel() throws Exception {
QueueChannel channel = new QueueChannel();
AsyncMessagingTemplate template = new AsyncMessagingTemplate();
template.setDefaultDestination(channel);
Future<?> result = template.asyncReceiveAndConvert();
sendMessageAfterDelay(channel, new GenericMessage<String>("test"), 200);
long start = System.currentTimeMillis();
assertNotNull(result.get(10000, TimeUnit.MILLISECONDS));
long elapsed = System.currentTimeMillis() - start;
assertEquals("test", result.get());
assertTrue(elapsed >= 200 - safety);
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class AsyncMessagingTemplateTests method asyncConvertAndSendWithResolvedChannel.
@Test
public void asyncConvertAndSendWithResolvedChannel() throws Exception {
StaticApplicationContext context = new StaticApplicationContext();
context.registerSingleton("testChannel", QueueChannel.class);
context.refresh();
QueueChannel channel = context.getBean("testChannel", QueueChannel.class);
AsyncMessagingTemplate template = new AsyncMessagingTemplate();
template.setBeanFactory(context);
Future<?> future = template.asyncConvertAndSend("testChannel", "test");
assertNull(future.get(10000, TimeUnit.MILLISECONDS));
Message<?> result = channel.receive(0);
assertEquals("test", result.getPayload());
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class AsyncMessagingTemplateTests method asyncReceiveWithTimeoutException.
@Test(expected = TimeoutException.class)
public void asyncReceiveWithTimeoutException() throws Exception {
AsyncMessagingTemplate template = new AsyncMessagingTemplate();
Future<Message<?>> result = template.asyncReceive(new QueueChannel());
result.get(100, TimeUnit.MILLISECONDS);
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class AsyncMessagingTemplateTests method asyncConvertAndSendWithDefaultChannel.
@Test
public void asyncConvertAndSendWithDefaultChannel() throws Exception {
QueueChannel channel = new QueueChannel();
AsyncMessagingTemplate template = new AsyncMessagingTemplate();
template.setDefaultDestination(channel);
Future<?> future = template.asyncConvertAndSend("test");
assertNull(future.get(10000, TimeUnit.MILLISECONDS));
Message<?> result = channel.receive(0);
assertEquals("test", result.getPayload());
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class CorrelationHandlerTests method testSplitterResequencer.
@Test
public void testSplitterResequencer() {
QueueChannel replyChannel = new QueueChannel();
this.splitInput.send(MessageBuilder.withPayload("").setReplyChannel(replyChannel).setHeader("foo", "bar").build());
for (int i = 0; i < 12; i++) {
Message<?> receive = replyChannel.receive(2000);
assertNotNull(receive);
assertFalse(receive.getHeaders().containsKey("foo"));
assertTrue(receive.getHeaders().containsKey("FOO"));
assertEquals("BAR", receive.getHeaders().get("FOO"));
assertEquals(i + 1, receive.getPayload());
}
}
Aggregations