Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: ChannelNameResolver exception with M4 build

  1. #1

    Question ChannelNameResolver exception with M4 build

    I am using a ChannelNameResolver to direct JMS responses to appropriate queues.

    Its defined as follows in spring config :

    Code:
    <beans:bean id="dynaRouter"
    
    class="org.springframework.integration.router.SingleChannelRouter">
    
    <beans:property name="channelNameResolver" ref="MyResponseRouteResolver" />
    
    <beans:property name="channelRegistry" ref="internal.MessageBus" />
    
    </beans:bean>
    With M3 jars this works fine and response is channeled and sent appropriately..

    With M4 jars (SI build dated 20080414 ) though I see the following exception , though if you notice I do have both 'channelNameResolver' and 'channelRegistry' defined above :

    org.springframework.integration.ConfigurationExcep tion: router configuration requires either a 'channelResolver' or both 'channelNameResolver' and 'channelRegistry' at org.springframework.integration.router.SingleChann elRouter.resolveChannel(SingleChannelRouter.java:7 7)
    at org.springframework.integration.router.SingleChann elRouter.resolveChannels(SingleChannelRouter.java: 65)
    at org.springframework.integration.router.AbstractRou tingMessageHandler.handle(AbstractRoutingMessageHa ndler.java:79)
    at org.springframework.integration.endpoint.DefaultMe ssageEndpoint.handle(DefaultMessageEndpoint.java:2 56)
    at org.springframework.integration.dispatcher.Default MessageDistributor.distribute(DefaultMessageDistri butor.java:93)
    at org.springframework.integration.dispatcher.Default MessageDispatcher.doDispatch(DefaultMessageDispatc her.java:183)
    at org.springframework.integration.dispatcher.Default MessageDispatcher.access$2(DefaultMessageDispatche r.java:176)
    at org.springframework.integration.dispatcher.Default MessageDispatcher$DispatcherTask.run(DefaultMessag eDispatcher.java:217)
    at org.springframework.integration.scheduling.SimpleM essagingTaskScheduler$MessagingTaskRunner.run(Simp leMessagingTaskScheduler.java:136)


    What has changed ?

  2. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,854

    Default

    I've attempted to reproduce this based on your configuration excerpt, but the routing is working as expected, and I am not seeing any errors. Are there any other router instances that may be mis-configured? If not, can you provide more information about other components and how this is being invoked when you see that error?

    Thanks,
    Mark

  3. #3

    Default Further

    As the same config works fine with M3 jars , I dont think there is any problem with the remaining config .

    The logic is being invoked on message being sent to a channel configured as follows , the channelNameResolver then sends to appropriate jms-target channels ..

    Code:
    <channel id="dummyChannel" />
    	
    	<endpoint input-channel="dummyChannel" handler-ref="dynaRouter" />
    
    	<!-- Dynamic list of recipients -->
    	<beans:bean id="dynaRouter"		class="org.springframework.integration.router.SingleChannelRouter">
    		<beans:property name="channelNameResolver"
    			ref="MyResponseRouteResolver" />
    		<beans:property name="channelRegistry"
    			ref="internal.MessageBus" />
    	</beans:bean>
    Since it fails on the initial stages, it does not even reaches the custom router class.

  4. #4
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,854

    Default

    Are you defining the MessageBus explicitly (with a <bean/> defintion) or using the namespace (<message-bus/>)?

  5. #5

    Default message bus definition

    <message-bus auto-create-channels="true" error-channel="errorChannel"/>

    The internal.MessageBus is the bean reference defined by SI by the above config I presume.

  6. #6
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,854

    Default

    Are you sending Messages to "dummyChannel" programmatically - or is it a reply channel for another endpoint/source-adapter?

    I'm just trying to put all of the pieces together since I am having a hard time understanding how this could happen unless somehow the router is actually being invoked before its dependencies have even been injected.

  7. #7

    Default

    Sorry for the confusion , yes, I am sending message to the dummyChannel programatically.

    I have JMS messages coming in , read through jms-source and the response being sent back programatically to dummy channel , channelNameResolver and then jms-target invocations.

    Is 'internal.MessaageBus' still a bean defined by SI ?

  8. #8
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,854

    Default

    The name "internal.MesageBus" is still used for the MessageBus instance, and I've copied your configuration with that and it works. However, this must be a timing issue where the JMS source starts receiving messages before the router is even configured (not to mention that the MessageBus bean name is obviously intended to be an "internal" name). In M4, we will be providing the ChannelRegistry to the ChannelRegistryAware beans more eagerly (most likely with a dedicated BeanPostProcessor implementation). For now, you might be able to provide a "depends-on" attribute between the bean definitions. Are you using a JmsMessageDrivenSourceAdapter or a JmsPollingSourceAdapter?

  9. #9

    Default

    Following is the jms-target definition that I use

    Code:
    <jms-target id="wmqProvider1"
    		jms-template="ibmMQJmsRequestTemplate501"
    		channel="MyResponseChannel1"/>
    
    <jms-target id="wmqProvider2"
    		jms-template="ibmMQJmsRequestTemplate601"
    		channel="MyResponseChannel2" />
    
    <channel id="MyResponseChannel1" />
    <channel id="MyResponseChannel2" />
    <channel id="dummyChannel" />
    	
    <endpoint input-channel="dummyChannel" handler-ref="dynaRouter" />
    
    <!-- Dynamic list of recipients -->
    <beans:bean id="dynaRouter"
    class="org.springframework.integration.router.SingleChannelRouter">
        <beans:property name="channelNameResolver"	ref="MyResponseRouteResolver" />
        <beans:property name="channelRegistry"
    			ref="internal.MessageBus" />
    </beans:bean>
    Do I need to define as <beans:bean .. > to be able to use depends-on for the dynaRouter ?

  10. #10

    Default

    I took the source for SingleChannelRouter and put a sysOut in the resolveChannel() method for channelNameResolver and channelRegistry and turns out the registry is not being set, so returning null.

    Meaning, the 'internal.MessageBus' reference is not being resolved ,or being reset somewhere..

    Can you give me pointers to where this bean is defined and where I can look further ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •