Hi all,
I am new to Spring Integration but i have been going through several sample examples on how to implement a simple poll based imap store mail receiver using spring integration.
I followed certain tutorials and came up with an app which unfortunately does not seem to work. Been looking around to see where the issue lies but i am afraid it might be something really fundamental.
In any case, i would be grateful if someone could point out my mistake and let me know where i went wrong.
Here is my application-context.xml file
My mailman class is a simple test class just to see if i am actually picking up anything.Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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-3.0.xsd http://www.springframework.org/schema/integration/mail http://www.springframework.org/schema/integration/mail/spring-integration-mail-2.0.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">true</prop> </util:properties> <mail:inbound-channel-adapter id="imapAdapter" store-uri="imaps://username:password@imap.gmail.com/INBOX" channel="receiveEmailChannel" should-delete-messages="false" should-mark-messages-as-read="true" auto-startup="true" java-mail-properties="javaMailProperties"> <int:poller fixed-rate="5000" max-messages-per-poll="10"/> </mail:inbound-channel-adapter> <int:channel id="receiveEmailChannel"/> <int:service-activator input-channel="receiveEmailChannel" ref="mailman" method="receive"/> <bean id="mailman" class="main.Mailman"> </bean> </beans>
Here is my main class, App.java (starter class per say)Code:package main; import javax.mail.Message; import javax.mail.internet.MimeMessage; public class Mailman { public void receive(MimeMessage message) { System.out.println("hello"); System.out.println(message); } }
When i run the application, the beans get loaded from the classpathresource as expected but nothing happens thereafter. If i dont add the infinite while loop the application terminates immediately without saying/doing anything. With the while loop it does nothing and just keeps running.Code:package main; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.xml.*; import org.springframework.core.io.ClassPathResource; import org.springframework.integration.*; import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.core.PollableChannel; import org.springframework.integration.support.MessageBuilder; public class App { /** * @param args */ public static void main(String[] args) { BeanFactory factory = new XmlBeanFactory(new ClassPathResource("application-context.xml")); //Mailman mailman = (Mailman)factory.getBean("mailman"); //MessageChannel receiveEmailChannel = (MessageChannel)factory.getBean("receiveEmailChannel"); //receiveEmailChannel.send((Message<String>)MessageBuilder.withPayload("test").build()); while(true){ } } }
When i uncomment the lines of code from the App.java file then i get the following error messages.
Read up a bit on these error messages but i am not really clear on the exact chain so i am not quite sure what i need to do to rectify the problem or even what the real problem is for that matter.Code:May 16, 2013 10:34:08 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from class path resource [application-context.xml] Exception in thread "main" org.springframework.integration.MessageDeliveryException: failed to send Message to channel 'receiveEmailChannel' at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:165) at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:128) at main.App.main(App.java:23) Caused by: java.lang.IllegalStateException: Dispatcher has no subscribers. at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:104) at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:97) at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:44) at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157) ... 2 more
Any advise is appreciated.
Cheers !


Reply With Quote
