use of org.springframework.integration.endpoint.PollingConsumer in project spring-integration by spring-projects.
the class ApplicationContextMessageBusTests method consumerSubscribedToErrorChannel.
@Test
public void consumerSubscribedToErrorChannel() throws InterruptedException {
TestApplicationContext context = TestUtils.createTestApplicationContext();
QueueChannel errorChannel = new QueueChannel();
context.registerChannel(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME, errorChannel);
final CountDownLatch latch = new CountDownLatch(1);
AbstractReplyProducingMessageHandler handler = new AbstractReplyProducingMessageHandler() {
@Override
public Object handleRequestMessage(Message<?> message) {
latch.countDown();
return null;
}
};
PollingConsumer endpoint = new PollingConsumer(errorChannel, handler);
endpoint.setBeanFactory(mock(BeanFactory.class));
context.registerEndpoint("testEndpoint", endpoint);
context.refresh();
errorChannel.send(new ErrorMessage(new RuntimeException("test-exception")));
latch.await(1000, TimeUnit.MILLISECONDS);
assertEquals("handler should have received error message", 0, latch.getCount());
context.stop();
}
use of org.springframework.integration.endpoint.PollingConsumer in project spring-integration by spring-projects.
the class ByteStreamWritingMessageHandlerTests method initialize.
@Before
public void initialize() {
stream = new ByteArrayOutputStream();
handler = new ByteStreamWritingMessageHandler(stream);
this.channel = new QueueChannel(10);
this.endpoint = new PollingConsumer(channel, handler);
scheduler = new ThreadPoolTaskScheduler();
this.endpoint.setTaskScheduler(scheduler);
scheduler.afterPropertiesSet();
trigger.reset();
endpoint.setTrigger(trigger);
endpoint.setBeanFactory(mock(BeanFactory.class));
}
use of org.springframework.integration.endpoint.PollingConsumer in project spring-integration by spring-projects.
the class CharacterStreamWritingMessageHandlerTests method initialize.
@Before
public void initialize() {
writer = new StringWriter();
handler = new CharacterStreamWritingMessageHandler(writer);
this.channel = new QueueChannel(10);
trigger.reset();
this.endpoint = new PollingConsumer(channel, handler);
scheduler = new ThreadPoolTaskScheduler();
this.endpoint.setTaskScheduler(scheduler);
scheduler.afterPropertiesSet();
trigger.reset();
endpoint.setTrigger(trigger);
endpoint.setBeanFactory(mock(BeanFactory.class));
}
use of org.springframework.integration.endpoint.PollingConsumer in project spring-integration by spring-projects.
the class JdbcOutboundGatewayParserTests method testMaxMessagesPerPollIsSet.
@Test
public void testMaxMessagesPerPollIsSet() {
setUp("JdbcOutboundGatewayWithPoller2Test-context.xml", this.getClass());
PollingConsumer pollingConsumer = this.context.getBean(PollingConsumer.class);
DirectFieldAccessor accessor = new DirectFieldAccessor(pollingConsumer);
Object source = accessor.getPropertyValue("handler");
accessor = new DirectFieldAccessor(source);
// JdbcPollingChannelAdapter
source = accessor.getPropertyValue("poller");
accessor = new DirectFieldAccessor(source);
Integer maxRowsPerPoll = (Integer) accessor.getPropertyValue("maxRowsPerPoll");
assertEquals("maxRowsPerPoll should default to 10", Integer.valueOf(10), maxRowsPerPoll);
}
use of org.springframework.integration.endpoint.PollingConsumer in project spring-integration by spring-projects.
the class JdbcOutboundGatewayParserTests method testReplyTimeoutIsSet.
@Test
public void testReplyTimeoutIsSet() {
setUp("JdbcOutboundGatewayWithPollerTest-context.xml", getClass());
PollingConsumer outboundGateway = this.context.getBean("jdbcOutboundGateway", PollingConsumer.class);
DirectFieldAccessor accessor = new DirectFieldAccessor(outboundGateway);
Object source = accessor.getPropertyValue("handler");
accessor = new DirectFieldAccessor(source);
source = accessor.getPropertyValue("messagingTemplate");
MessagingTemplate messagingTemplate = (MessagingTemplate) source;
accessor = new DirectFieldAccessor(messagingTemplate);
Long sendTimeout = (Long) accessor.getPropertyValue("sendTimeout");
assertEquals("Wrong sendTimeout", Long.valueOf(444L), sendTimeout);
}
Aggregations