Announcement Announcement Module
Collapse
No announcement yet.
'Dispatcher has no subscribers' Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 'Dispatcher has no subscribers'

    At work I am getting this error intermittently. I have designed a simple test case the same as the one I am using at work. For some reason it was working and then for no reason I can fathom it started failing with 'Dispatcher has no subscribers' . The only thing I can think is that something is being brought up in the wrong order. Here is the test

    JaxB annotated object with getters setters etc omitted

    Code:
    @XmlRootElement(name = "object")
    public class MyObject implements Serializable{
    
    	private static final long serialVersionUID = -5373141442895674583L;
    	private String value1;
    	private String value2;
    }
    Annotated Service taking the object as a parameter

    Code:
    @MessageEndpoint
    public class MyService {
    
    	@ServiceActivator
    	public void myMethod (MyObject val){
    		System.out.println(val);
    	}
    }
    The test case which should output hello world

    Code:
    @ContextConfiguration(locations = {"classpath:/jms-test-int.xml"})
    @RunWith(SpringJUnit4ClassRunner.class)
    public class MyServiceTest {
    
    	@Autowired
    	private MessageChannel toJMS;
    	
    	@Test
    	public void test() {
    		MessagingTemplate template = new MessagingTemplate();
    		template.convertAndSend(toJMS, new MyObject("hello", "world"));
    	}
    
    }
    Lastly the configuration

    Code:
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:int="http://www.springframework.org/schema/integration"
    	xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
    	xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
    		http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
    		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    		
    	<int:channel id="toJMS"/>
    
    	<int-jms:outbound-channel-adapter channel="toJMS" destination-name="com.sample.jms" message-converter="marshallingMessageConverter"/>
    
    	<int-jms:message-driven-channel-adapter channel="fromJMS" destination-name="com.sample.jms" message-converter="marshallingMessageConverter"/>
    
    	<int:channel id="fromJMS" />
    	
    	<int:service-activator input-channel="fromJMS" ref="myService"/>
    	
    	<bean id="myService" class="com.sample.jms.MyService"/>
    
    
    	<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    		<property name="brokerURL" value="vm://localhost"/>
    	</bean>
    	
    	<bean id="marshallingMessageConverter" class="org.springframework.jms.support.converter.MarshallingMessageConverter">
    		<property name="unmarshaller" ref="jaxbMarshaller" />
    		<property name="marshaller" ref="jaxbMarshaller" />
    	</bean>
    	
    	<bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller" >
    		<property name="packagesToScan">
    			<list>
    				<value>com.sample.jms</value>
    			</list>
    		</property>
    	</bean>
    			
    </beans>
    Now I have not been able to reproduce this error here on my home pc (powerful linux box) but on my slower Windows XP machine at work it is failing intermittently. When I left today it was failing consistently until I removed the message-converters and just changed the service activator to take a string argument. Has anyone run into this before?

    Thanks,
    Bill

  • #2
    Ok. So I am back at work there is one difference I also have a

    Code:
    <int:annotation-config />
    but I can't see why that would make a difference. I just ran this test case 5 times. 2 times it worked, 1 time it was green bar with no output and 2 times it failed with a 'Dispatcher has no subscribers' error. This is just strange to me, does the context need to be refreshed somehow after fully initializing the JMS stuff before the test case uses it? Am I missing something?

    Comment


    • #3
      Dug around the forums here and found some info on how to get some better debugging going

      It looks like the framework is stopping everything and it removes the service-activator as a subscriber and then immediately after there is a preSend to the channel that the service-activator was subscribed to and this is what is causing the error

      Comment


      • #4
        Ok, this is resolved. I was being stupid and forgot about the asynchronous aspect. The test case was ending before my message arrived. Basically I took the advice in the new Spring Integration in Action book and used a countdown latch to make sure I am waiting long enough before making my assertions.

        Thanks,
        Bill

        Comment

        Working...
        X