Rudi
Rudi

Reputation: 429

dispatcher has no subscribers - spring integration JMS

I want to add JMS to a existing spring integration project. The xml file that I want to change looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" 
   xmlns="http://www.springframework.org/schema/integration"
xmlns:jms="http://www.springframework.org/schema/integration/jms"
xmlns:int-http="http://www.springframework.org/schema/integration/http" xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
    http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
    http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http.xsd
    http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd">

<channel id="eventUpdateChannel" />

<chain input-channel="eventUpdateChannel" output-channel="eventUpdateChannelRouter">
(...)
</chain>
(...)
</bean>

and this workes fine, the messages that come through the eventUpdateChannel are processed.

After looking at examples from Spring Integration site I changed that xml file to this:

(...)
<channel id="eventUpdateChannel" />
<channel id="jmsEventUpdateChannel" />

<jms:message-driven-channel-adapter id="jmsIn" destination="inboundMessageQueue" channel="eventUpdateChannel" />
<jms:outbound-channel-adapter id="jmsOut" channel="jmsEventUpdateChannel" destination="inboundMessageQueue"/>

<chain input-channel="jmsEventUpdateChannel" output-channel="eventUpdateChannelRouter">
(...)

I've also added this part:

<!-- JMS -->
<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
    <property name="targetConnectionFactory">
        <bean class="org.apache.activemq.ActiveMQConnectionFactory">
            <property name="brokerURL" value="vm://localhost"/>
        </bean>
    </property>
    <property name="sessionCacheSize" value="10"/>
    <property name="cacheProducers" value="false"/>
</bean>

<bean id="inboundMessageQueue" class="org.apache.activemq.command.ActiveMQQueue">
    <constructor-arg value="queue.request"/>
</bean>

Now after the application is started and when it receives a message the message isn't processed and i get this warning:

org.springframework.integration.MessageDeliveryException: Dispatcher has no subscribers for channel eventUpdateChannel.

Upvotes: 3

Views: 6979

Answers (1)

Gary Russell
Gary Russell

Reputation: 174504

Your adapter is sending its data to eventUpdateChannel which no longer has anything subscribed.

Previously, the <chain/> was subscribed to it.

Based on your comment below, you need

<channel id="eventUpdateChannel" />

<jms:outbound-channel-adapter id="jmsOut" channel="eventUpdateChannel" destination="inboundMessageQueue"/>

<jms:message-driven-channel-adapter id="jmsIn" destination="inboundMessageQueue"   channel="jmsEventUpdateChannel" />

<channel id="jmsEventUpdateChannel" />

<chain input-channel="jmsEventUpdateChannel" output-channel="eventUpdateChannelRouter">

If all you are doing is using JMS for persistence, you can remove the adapters and simply make eventUpdateChannel a jms-backed channel. If you are using it to distribute work to other JVMs, then adapters are the right choice.

Upvotes: 1

Related Questions