Announcement Announcement Module
Collapse
No announcement yet.
Difference between Router and If condition? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Difference between Router and If condition?

    Why can't I use a simple If condition instead of routers? What is the difference? Ofcourse, a router is also simple but why/when a router is required?

    Code:
        <si:router input-channel="postProcessing" ref="postProcessingRouter" method="route"/>
    
        <bean id="postProcessingRouter" class="com.xx.MessageRouter">
            <property name="destinations">
                <map>
                    <entry key="PREVALIDATED" value="prevalidation"/>
                </map>
            </property>
            <property name="defaultDestination" value="toSplit"/>
        </bean>

  • #2
    Would a <header-value-router/> do the job?

    Comment


    • #3
      Routers are based on conditions, so naturally they are implemented via 'if' and 'switch case" constructs. But there is a difference between using an 'if' statement in your business logic when you trying to process message differently based on the data in the message vs routing message to a different channel (thus different process) based on some pre-condition.
      Think of it as separation of concerns between Integration logic (routers) and Business logic (generic 'if' construct)

      Comment

      Working...
      X