Announcement Announcement Module
Collapse
No announcement yet.
MapBasedChannelResolver in RC1 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MapBasedChannelResolver in RC1

    This class used to be in spring-integration-core.jar until M7. However, I am not finding it RC1. I checked out the sources as well. Is this intentional?

    Thanks in advance.

  • #2
    Yes, it was removed. Before I go in details, could u please describe the use case that makes u use this class?

    Comment


    • #3
      I am using it to resolve channel based on map values. Here is my config.

      Code:
      <si:router input-channel="convertChannel" method="checkRequiredFields" channel-resolver="checkResolver" ref="validationProcessor" />
            
          <bean id="checkResolver" class="org.springframework.integration.channel.MapBasedChannelResolver">
      		<property name="channelMap">
      			<map>
      				<entry key="true" value-ref="checkedChannel" />
      				<entry key="false" value-ref="errorResponseChannel" />
      			</map>
      		</property>
      	</bean>
      My application is erroring out without this class.

      Thanks.

      Comment


      • #4
        Sorry, I missed to give further details.

        Once I receive a request, I check for some required fields. If they are present they are routed to be processed; or else the request will be rejected. I am using map based channel resolver to determine which way the message would be routed in combination with the router.

        Thank you!

        Comment


        • #5
          Bobby

          The configuration you posted was all i needed to understand your use case
          Between M7 and RC1 Routers underwent major refactoring which now makes configuration of every router much simpler and most importantly more consistent. It also introduces a support for DynamicRouter pattern across all routers.
          I'll try to be brief, but if you can also read the new section in the docs "Dynamic Router support" to get more details.
          Anyway, your configuration is perfectly valid with the exception of MapBasedChannelResolver being removed (you can still inject your own implementation of ChannelResolver though), but it is also unnecessary since every router by default is injected with BeanFactoryChannelResolver.
          I also understand that BeanFactoryChannelResolver by itself is not going to help you in your use case simply because your router implementation returns a boolean value 'true' or 'false' and you want to map this value to a channel and that is why you were using CR.
          Well, we removed MapBasedChannelResolver in favor of defining a channel identifier map at the base class for all routers. This map is empty by default but. . .
          If you think about routing use case it consists of 3 steps:
          1. Compute channel identifier - that is what your implementation does
          2. Map channel identifier to channel name - this is what the MapBasedChannelResolver did
          3. Resolve channel name to MessageChannel instance - this is done by BeanFactoryChannelResolver
          Step 2 is optional which means that if channel identifier map is empty, then channel identifier will be treated as channel name, which means in your case if you had two channels named 'true' and 'false' you don't need any mappings at all. But obviously those are bad names and that is why you want to explicitly map these values to specific channel instances.
          All you need to do is this:
          Code:
          <si:router input-channel="convertChannel" method="checkRequiredFields"  ref="validationProcessor">
             <mapping value="true" channel="checkedChannel"/>
             <mapping value="false" channel="errorResponseChannel"/>
          </si:router>
          Now, when your router implementation returns 'true' or 'false', Step 2 will resolve those values to the channels identified via mapping configuration.
          Last edited by oleg.zhurakousky; Oct 29th, 2010, 01:20 PM.

          Comment


          • #6
            Even simpler
            Code:
            <si:router input-channel="convertChannel" method="checkRequiredFields"  ref="validationProcessor" default-output-channel="errorResponseChannel">
               <mapping value="true" channel="checkedChannel"/>
            </si:router>

            Comment


            • #7
              Thank you! As always, you made my day

              Best regards.

              Comment

              Working...
              X