Announcement Announcement Module
Collapse
No announcement yet.
ChannelNameResolver exception with M4 build Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      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.

      Comment


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

        Comment


        • #5
          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.

          Comment


          • #6
            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.

            Comment


            • #7
              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 ?

              Comment


              • #8
                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?

                Comment


                • #9
                  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 ?

                  Comment


                  • #10
                    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 ?

                    Comment


                    • #11
                      DefaultMessageEndpoint.afterPropertiesSet

                      On further debugging I see that the AbstractRoutingMessageHandler setChannelRegistry() is being called twice , first time with the correct value and second time with a null. The second call is being made from DefaultMessageEndpoint.afterPropertiesSet() line :192 which is as follows :

                      Code:
                      public void afterPropertiesSet() {
                      if (this.handler == null) {
                      	return;
                      }
                      if (this.handler instanceof ChannelRegistryAware) {
                      //Setting to null at this point
                      ((ChannelRegistryAware) this.handler).setChannelRegistry(this.channelRegistry);
                      		}
                      Comparing the old and new source, turns out this is a new change in M4, which is setting the channelRegistry to null at this point and hence the error later on.

                      Is this correct and how can I get around this ?

                      Comment


                      • #12
                        The MessageBus is supposed to be providing the channelRegistry to that endpoint, but it is apparently happening after the initialization callback. Can you please submit a bug report in jira?

                        Thanks,
                        Mark

                        Comment


                        • #13
                          JIRA issue created

                          Please check : http://jira.springframework.org/browse/INT-202
                          Please let us know when this will be resolved.


                          Thanks a lot for your help!
                          Last edited by diippi; Apr 21st, 2008, 03:31 PM. Reason: Editing issue

                          Comment


                          • #14
                            I added a short-term fix for this issue (available on the SVN HEAD or will be in tonight's snapshot). Basically, it is just doing a null check so that the endpoint will never set the channelRegistry before it has been provided by the MessageBus. However, the long term solution for this will involve some changes in the initialization process. Therefore I am keeping the issue open.

                            If you get a chance, please do update after the next nightly snapshot and let me know if your problem goes away.

                            Regards,
                            Mark

                            Comment


                            • #15
                              Thanks Mark..I have taken the latest from svn and the short term fix does works..I will be keeping an eye out on the JIRA too.

                              Comment

                              Working...
                              X