Configuring Router Context

Router uses XML configuration to configure routing and mediation rules which are added to a router-context.xml of the OMS. This file is available inside $AF_HOME/roles/omsServer/standalone/services/omsServer/omsServer-4.0.0-SNAPSHOT.jar.

To submit an order, consider an example with engine name as Fulfillment Provisioning.

The following sections take you through the process of configuring the router context:

  1. Create an instance of submit order router.
    1. Create a JMS template. To do this, make the following changes:
      <bean id="kpsaJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
      		<property name="connectionFactory" ref="kpsaConnectionFactory"/>
      		<property name="destinationResolver" ref="beoDestinationResolver"/>
      		<property name="pubSubDomain" value="false"/>
      </bean>
      
      1. Create a connection factory.
        <bean id="kpsaConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
        	<constructor-arg>
              	<bean class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName" value="GenericConnectionFactory"/>
        <property name="jndiTemplate" ref="kpsaJndiTemplate"/>
                  	</bean>
              </constructor-arg>
            	<property name="reconnectOnException" value="true"/>
            	<property name="cacheProducers" value="true"/>  
        </bean>
        
      2. Add a JNDI template.
        <bean id="kpsaJndiTemplate" class="org.springframework.jndi.JndiTemplate">
        	<property name="environment">
        		<props>
        			<prop key="java.naming.provider.url">tcp://${com.tibco.af.oms.jms.jndi.host}:${com.tibco.af.oms.jms.jndi.port}
        </prop>
        			<prop key="java.naming.factory.initial">${com.tibco.af.oms.jms.jndi.initialContextFactory}	</prop>
        			<prop key="java.naming.security.principal">${com.tibco.af.oms.jms.jndi.security.principal}	</prop>
        <!-- <prop key="java.naming.security.credentials">${jms.jndi.security.credentials}</prop>  -->				
        		</props>
        	</property>
        </bean>
        
    2. Assign a destination queue.
      <bean id="kpsaSubmitOrderDestination" class="com.tibco.tibjms.TibjmsQueue">
      		<constructor-arg value="${com.tibco.af.oms.router.destination.kpsaSubmitOrder}" />
      </bean>
      
    3. Create an instance of Router Message Create.
      <bean id="kpsaSubmitMessage" class="com.tibco.aff.oms.router.RouterMessageCreator"/>
    4. Create an instance of Router.
      <bean id="kpsaSubmitOrderRouter" class="com.tibco.aff.oms.router.RouterProcessor">
      <property name="jmsTemplate"><ref local="kpsaJmsTemplate"/></property>
      <property name="destination"><ref local="kpsaSubmitOrderDestination"/></property>
      <property name="messageCreator"><ref local="kpsaSubmitMessage"/></property>
               </bean>
      
    5. Add an entry to router context for the required action.
      <routeContext id="routerContext" xmlns="http://camel.apache.org/schema/spring">
         
          <route id="orderSubmitRoute">       
            <from uri="direct:tibco.aff.routerproxy.order.submit"/>
            <choice>
            		 <when>
            		 	<xpath>$orchestrator = 'IPC'</xpath>
            		 	<to uri="bean:ipcSubmitOrderRouter" pattern="InOnly" />
                           <transform>
                           <simple> IPC</simple>
                          </transform>
                         
                  		<to uri="bean:routerDataProcessor"/>
                    </when>
                    <when>
            		 	<xpath>$orchestrator = 'KPSA'</xpath>
            		 	<to uri="bean:kpsaSubmitOrderRouter" pattern="InOnly" />
                           <transform>
                           <simple>KPSA</simple>
                          </transform>
                         
                  		<to uri="bean:routerDataProcessor"/>
                    </when>
                  <otherwise>
                        <to uri="bean:beoSubmitOrderRouter" pattern="InOnly" />
                          <transform>
                          	<simple>AFO</simple>
                          </transform>
                    
                  		<to uri="bean:routerDataProcessor"/>
                           
                   </otherwise>
                
              </choice>
          </route>
  2. Changes to ConfigValues using AF Configurator.
    1. Add a new property in the config values for the submit order destination according to 1.b (Assign a destination queue).