Announcement Announcement Module
Collapse
No announcement yet.
inbound channel adapter with Queue is not working throwing exception Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • inbound channel adapter with Queue is not working throwing exception

    I have the following spring-integration configuration v1.0.4.

    Code:
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:mail="http://www.springframework.org/schema/integration/mail"
    xmlns:int="http://www.springframework.org/schema/integration"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
        http://www.springframework.org/schema/integration/mail
        http://www.springframework.org/schema/integration/mail/spring-integration-mail-2.1.xsd 
        http://www.springframework.org/schema/util 
        http://www.springframework.org/schema/util/spring-util-2.0.xsd">
    
    
        <util:properties id="javaMailProperties">
        <prop key="mail.imap.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
        <prop key="mail.imap.socketFactory.fallback">false</prop>
        <prop key="mail.store.protocol">imaps</prop>
        <prop key="mail.debug">false</prop>
    </util:properties>
    
     <mail:inbound-channel-adapter id="imapAdapter"
                                      store-uri="imaps://user:pass@domain:993/inbox"                                    
                                      channel="recieveEmailChannel"
                                      auto-startup="true"                                      
                                      java-mail-properties="javaMailProperties">
        <int:poller> 
        <int:interval-trigger initial-delay="1000" interval="2000"
        fixed-rate="true"/>
        </int:poller>
    </mail:inbound-channel-adapter>
    
    <int:channel id="recieveEmailChannel">        
        <int:queue/>
        <int:interceptors>
            <int:wire-tap channel="logger"/>
        </int:interceptors>
    </int:channel>
    
    <int:logging-channel-adapter id="logger" level="DEBUG"/>
    
    <int:service-activator input-channel="recieveEmailChannel" ref="emailReceiverService" method="receive"/>
    
    <bean id="emailReceiverService" class="com.mycompany.DefaultEmailReceiverUtilService">
    </bean>
    DefaultEmailReceiverUtilService

    Code:
    public class DefaultEmailReceiverUtilService implements
            EmailReceiverUtilService
    {
    
        public void receive(Message<?> message)
        {
            //Processing the emails
        }
    }

    Question I wanted to process in a multi threaded asynchronous manner. So I have added
    Code:
    <int:queue/>
    , but I am receiving the following exception:

    Code:
    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.config.ConsumerEndpointFactoryBean#0': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No poller has been defined for endpoint 'org.springframework.integration.config.ConsumerEndpointFactoryBean#0', and no default poller is available within the context.
    If I comment out
    Code:
    <int:queue/>
    then no exceptions but it is sequential and synchronous.
    How to make it asynchronous and multithreaded?

  • #2
    ...and no default poller is available within the context.
    When using queue channels, you either have to add a <poller/> element to the <service-activator/> or declare a top-level <poller ... default="true"/>.

    You also might want to consider using an ExecutorChannel so the handoff to another thread is immediate rather than waiting for a poll.

    http://static.springsource.org/sprin...ecutor-channel

    http://static.springsource.org/sprin...xecutorchannel

    Comment

    Working...
    X