use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class EnableIntegrationTests method testSourcePollingChannelAdapterOutputChannelLateBinding.
@Test
public void testSourcePollingChannelAdapterOutputChannelLateBinding() {
QueueChannel testChannel = new QueueChannel();
ConfigurableListableBeanFactory beanFactory = (ConfigurableListableBeanFactory) this.context.getAutowireCapableBeanFactory();
beanFactory.registerSingleton("lateBindingChannel", testChannel);
beanFactory.initializeBean(testChannel, "lateBindingChannel");
this.autoCreatedChannelMessageSourceAdapter.start();
Message<?> receive = testChannel.receive(10000);
assertNotNull(receive);
assertEquals("bar", receive.getPayload());
this.autoCreatedChannelMessageSourceAdapter.stop();
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class AsyncMessagingTemplateTests method asyncReceiveAndConvertWithResolvedChannel.
@Test
public void asyncReceiveAndConvertWithResolvedChannel() 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<?> result = template.asyncReceiveAndConvert("testChannel");
sendMessageAfterDelay(channel, new GenericMessage<String>("test"), 200);
long start = System.currentTimeMillis();
assertNotNull(result.get(10000, TimeUnit.MILLISECONDS));
long elapsed = System.currentTimeMillis() - start;
assertTrue(elapsed >= 200 - safety);
assertEquals("test", result.get());
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class AsyncMessagingTemplateTests method asyncSendWithExplicitChannel.
@Test
public void asyncSendWithExplicitChannel() throws Exception {
QueueChannel channel = new QueueChannel();
AsyncMessagingTemplate template = new AsyncMessagingTemplate();
Message<?> message = MessageBuilder.withPayload("test").build();
Future<?> future = template.asyncSend(channel, message);
assertNull(future.get(10000, TimeUnit.MILLISECONDS));
Message<?> result = channel.receive(0);
assertEquals(message, result);
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class AsyncMessagingTemplateTests method asyncSendWithTimeoutException.
@Test(expected = TimeoutException.class)
public void asyncSendWithTimeoutException() throws Exception {
QueueChannel channel = new QueueChannel(1);
channel.send(MessageBuilder.withPayload("blocker").build());
AsyncMessagingTemplate template = new AsyncMessagingTemplate();
Future<?> result = template.asyncSend(channel, MessageBuilder.withPayload("test").build());
result.get(100, TimeUnit.MILLISECONDS);
}
use of org.springframework.integration.channel.QueueChannel in project spring-integration by spring-projects.
the class AsyncMessagingTemplateTests method asyncSendWithDefaultChannel.
@Test
public void asyncSendWithDefaultChannel() throws Exception {
QueueChannel channel = new QueueChannel();
AsyncMessagingTemplate template = new AsyncMessagingTemplate();
template.setDefaultDestination(channel);
Message<?> message = MessageBuilder.withPayload("test").build();
Future<?> future = template.asyncSend(message);
assertNull(future.get(10000, TimeUnit.MILLISECONDS));
Message<?> result = channel.receive(0);
assertEquals(message, result);
}
Aggregations