PDA

View Full Version : MessageDeliveryException: Dispatcher has no subscribers



rossgard
Nov 11th, 2009, 05:49 AM
Hi,

I am getting an error message when using the imap-idle-channel-adapter.

I am getting this error message:



DEBUG: org.springframework.integration.mail.ImapIdleChann elAdapter - received 15 mail messages
DEBUG: org.springframework.integration.channel.DirectChan nel - preSend on channel 'mailInputChannel', message: [Payload=javax.mail.internet.MimeMessage@922804][Headers={springintegration_id=74a7e293-7255-4ceb-adff-0f87be7f1753, springintegration_timestamp=1257936337453}]
Exception in thread "SimpleAsyncTaskExecutor-1" org.springframework.integration.message.MessageDel iveryException: Dispatcher has no subscribers.
at org.springframework.integration.dispatcher.Unicast ingDispatcher.doDispatch(UnicastingDispatcher.java :97)
at org.springframework.integration.dispatcher.Unicast ingDispatcher.dispatch(UnicastingDispatcher.java:9 0)
at org.springframework.integration.channel.AbstractSu bscribableChannel.doSend(AbstractSubscribableChann el.java:43)
at org.springframework.integration.channel.AbstractMe ssageChannel.send(AbstractMessageChannel.java:116)
at org.springframework.integration.channel.AbstractMe ssageChannel.send(AbstractMessageChannel.java:94)
at org.springframework.integration.channel.MessageCha nnelTemplate.doSend(MessageChannelTemplate.java:22 3)
at org.springframework.integration.channel.MessageCha nnelTemplate.send(MessageChannelTemplate.java:180)
at org.springframework.integration.endpoint.MessagePr oducerSupport.sendMessage(MessageProducerSupport.j ava:51)
at org.springframework.integration.mail.ImapIdleChann elAdapter.access$2(ImapIdleChannelAdapter.java:1)
at org.springframework.integration.mail.ImapIdleChann elAdapter$IdleTask.run(ImapIdleChannelAdapter.java :125)
at java.lang.Thread.run(Thread.java:595)


As far as I know the error message says that nothing listens on the mailInputChannel, but I canīt find the error.

My configuration:



<si-mail:imap-idle-channel-adapter id="mailin"
store-uri="imap://*** imap uri here ***" channel="mailInputChannel" should-delete-messages="false"
java-mail-properties="mailProperties"/>

<util:properties id="mailProperties">
<beans:prop key="mail.debug">true</beans:prop>
</util:properties>

<si:channel id="mailInputChannel" />

<si:service-activator input-channel="mailInputChannel" method="handleMessage">
<beans:bean class="org.test.activator.mail.MailServiceActivator" />
</si:service-activator>


Service Activator:




public class MailServiceActivator {

public void handleMessage(MimeMessage message) {
logger.debug("Activator called with message: " + message);
}
}



Test:



public class MailIntegration {

public static void main(String[] args) {
AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext(new String[]{"/integration-mail-beans.xml"}, MailIntegration.class);
applicationContext.stop();
}
}


When I run the code without the imap-adapter all works fine. The service activator reads messages from the mailInputChannel.

I have tried with annotations and without annotations, but without luck.

I am using Spring Integration 1.0.3-RELEASE.

Any pointers?

oleg.zhurakousky
Nov 11th, 2009, 08:13 AM
Are you sure you have nothing else configured?
I just ran your config and it works just fine.
Oleg

rossgard
Nov 11th, 2009, 09:24 AM
Are you sure you have nothing else configured?
I just ran your config and it works just fine.
Oleg
Ok, thanks!
I don`t think that I have anything else configured. I`ll check.

Kurt

rossgard
Nov 12th, 2009, 03:35 AM
I have tested with a clean project now and I still experience the same error message. I have also checked that I am using the required dependencies for spring integration 1.0.3.RELEASE. It's a puzzle ;)

I will try the 2.0 Milestone release.

Mark Fisher
Nov 12th, 2009, 06:48 AM
It might be related to this issue that was resolved in 2.0 M1:
http://jira.springframework.org/browse/INT-845

If not, then we need to take a look at it, since that same issue could apply here (ordering of startup) even though the imap-idle adapter is itself event-driven.

Please let us know if it works ok with 2.0 M1, and if not, can you please open a new issue?

Thanks,
Mark

rossgard
Nov 12th, 2009, 08:20 AM
It does not work with 2.0 M1 either. I get the same error message.

Issue opened: http://jira.springframework.org/browse/INT-884

Mark Fisher
Nov 12th, 2009, 11:04 AM
Thank you.

By the way, as a workaround you should be able to set auto-startup="false" on the adapter, and then start() it manually in some code that is invoked later (e.g. a custom ApplicationListener reacting to a ContextRefreshedEvent should do the trick).

rossgard
Nov 13th, 2009, 02:35 AM
Hi again, and thanks for the follow up!

It works after I added the custom ApplicationListener and removed stop() from the test code.

r1c4r60
Dec 14th, 2009, 11:52 PM
public class MailIntegration {

public static void main(String[] args) {
AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext(new String[]{"/integration-mail-beans.xml"}, MailIntegration.class);
applicationContext.stop();
}
}

The only thing that needs to be done in order to run this example is:

REMOVE THE "applicationContext.stop()" because in that point you are loosing all references to the pre instantiated beans (handlers) therefore
Dispatcher has no subscribers.. All handlers are already null when the message event happens.

Mark Fisher
Dec 23rd, 2009, 06:58 PM
Kurt,

Can you please try this with the *trunk* version? We're now relying on some enhancements to the lifecycle processing in Spring 3.0 which includes ordered shutdown. I would like to know if that may have resolved the issue.

Thanks,
Mark

hermod
Feb 13th, 2012, 03:19 AM
I am experiencing the same problem in 2.1. I have a jms-channel at the end of my intergration and In order to not get the above described error I need to set auto-startup="false" and start it from within code.

oleg.zhurakousky
Feb 13th, 2012, 06:15 AM
Cn you post your configuration? The problem is in your configuration. You have a DirectChannel that has no subscribers

Mark Fisher
Feb 13th, 2012, 06:29 AM
Actually, since you stated this occurs with a JMS channel, and that you can avoid it by setting auto-startup to false, it's likely similar but not the same as the DirectChannel case Oleg mentions. The similarity lies in the fact that a JMS channel also has its own dispatcher.

My first question would be, based on your statement that the JMS channel is at the *end* of your flow, is it only intended to be the last component in the flow? If so, I think you'd be better off using a JMS outbound-channel-adapter.

Hope that helps,
Mark

hermod
Feb 13th, 2012, 06:36 AM
Your right - The JMS channel (Publish/Subscribe) is at the end of the flow. I did add inn a subscriber, and then auto-start="true" worked. Before adding in a subscriber I had to start it up after the other channels had started.

By the way I am doing a project based on the ClusterController stuff that Oleg showed at the SpringOne in Chicago last fall.

oleg.zhurakousky
Feb 13th, 2012, 06:38 AM
ClusterController? That's cool but i think you meant Gary and Dave (the two guys who demonstrated that)

hermod
Feb 13th, 2012, 06:42 AM
My bad - You are absolutly right