tutorial routes with split - assimbly/gateway GitHub Wiki

In the previous tutorial we created a simple route. In this tutorial, you learn how to create multiple routes with queues and a split.

Step 1: Create a route

  • On the flows page, click on "Actions Menu" button and then "New route".
  • Give the flow the name: "ComplexRoute".

Step 2: Configure the inbound route

  • On the first route step, create a "New route" (Plus button).
  • Name the route "InboundXML".
  • Add the following XML in the XML Editor:
<route>
    <from uri="sjms:TestQ1?connectionFactory=#bean:1234"/>
    <log message="Message received"/>
    <to uri="direct:split"/>
</route>
  • Save the route.

  • Choose "Add" --> "Connection"

  • Select connection "EmbeddedBroker"

Note:

The connection was created in an earlier tutorial. Check this tutorial on message queueing if the connection isn't selectable.The connection has an id. In our example, it's 1234. Update the id with the correct id! The id can be found to click to edit the connection: embeddedBroker.

Step 3: Configure the split route

  • Choose "Add" --> "Route" .
  • On the new step select "New route" (Plus button).
  • Name the route "SplitXML".
  • Add the following XML in the XML Editor:
<route>
    <from uri="direct:split"/>
    <split>
        <xpath>//names/name</xpath>
        <to uri="direct:outbound"/>
    </split>
</route>

Step 4: Configure the outbound route

  • Choose "Add" --> "Route"
  • On the new step create a "New route" (Plus button).
  • Name the route "OutboundXML".
  • Add the following XML in the XML Editor:
<route>
    <from uri="direct:outbound"/>
    <log message="Outbound XML"/>
    <to uri="sjms:TestQ2?connectionFactory=#bean:1234"/>
</route>

Note: Update the connection ID again!*

  • Save the route.

  • Choose "Add" --> "Connection"

  • Select connection "EmbeddedBroker"

  • Save the flow.

Step 4: Start flow and broker

  • Make sure the broker is running (Go to Broker --> Manage to check if the broker is started).
  • Start the flow "ComplexRoute" on the Flows manage page.

Note: Queues are automatically generated. However, you can also go to the 'Broker --> Queues' page and create the queues manually.

Step 5: Test the flow

  • Go to Broker --> Queues --> TestQ1 --> Send.
  • Paste the following XML:
<names>
    <name>
       <firstname>John</firstname>
       <lastname>Doe</lastname>
    </name>
    <name>
       <firstname>Michael</firstname>
       <lastname>Kay</lastname>
    </name>
    <name>
       <firstname>Jane</firstname>
       <lastname>Smith</lastname>
    </name>
</names>

SendMessage

  • Send the XML (Actions --> Send and Return).

Result are three files on TestQ2 (The Queues page is refreshed every 5 seconds). Browse the queue to see the individual messages.

BrowseMessages


You can continue to the next tutorial to find out how to run flows in alternative ways (outside using the user interface, which we have done so far).

⚠️ **GitHub.com Fallback** ⚠️