INT-1952 fixed ConsumerEndpointFactoryBean to ensure the Polling Consumer is created with propper ErrorHandler

This commit is contained in:
Oleg Zhurakousky
2011-06-24 11:59:05 -04:00
parent d5bb9a8297
commit bad2debbf7
3 changed files with 27 additions and 0 deletions

View File

@@ -185,6 +185,8 @@ public class ConsumerEndpointFactoryBean
pollingConsumer.setAdviceChain(this.pollerMetadata.getAdviceChain());
pollingConsumer.setMaxMessagesPerPoll(this.pollerMetadata.getMaxMessagesPerPoll());
pollingConsumer.setErrorHandler(this.pollerMetadata.getErrorHandler());
pollingConsumer.setReceiveTimeout(this.pollerMetadata.getReceiveTimeout());
pollingConsumer.setBeanClassLoader(beanClassLoader);
pollingConsumer.setBeanFactory(beanFactory);

View File

@@ -33,6 +33,14 @@
<int:service-activator input-channel="serviceChannel" expression="payload/0"/>
<int:channel id="serviceWithPollerChannel">
<int:queue/>
</int:channel>
<int:service-activator input-channel="serviceWithPollerChannel" expression="5/0">
<int:poller fixed-rate="1000" error-channel="serviceErrorChannel"/>
</int:service-activator>
<int:channel id="eChannel">
<int:queue/>
</int:channel>
@@ -40,4 +48,8 @@
<int:channel id="errChannel">
<int:queue/>
</int:channel>
<int:channel id="serviceErrorChannel">
<int:queue/>
</int:channel>
</beans>

View File

@@ -26,10 +26,13 @@ import org.mockito.Mockito;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.SubscribableChannel;
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
import org.springframework.integration.message.GenericMessage;
/**
* @author Oleg Zhurakousky
@@ -87,6 +90,16 @@ public class PollerWithErrorChannelTests {
adapter.stop();
}
@Test
// INT-1952
public void testWithErrorChannelAndPollingConsumer() throws Exception{
ApplicationContext ac = new ClassPathXmlApplicationContext("PollerWithErrorChannel-context.xml", this.getClass());
MessageChannel serviceWithPollerChannel = ac.getBean("serviceWithPollerChannel", MessageChannel.class);
QueueChannel errChannel = ac.getBean("serviceErrorChannel", QueueChannel.class);
serviceWithPollerChannel.send(new GenericMessage<String>(""));
assertNotNull(errChannel.receive(1000));
}
public static class SampleService{
public String withSuccess(){
return "hello";