LibraryToggle FramesPrintFeedback

To add a content-based router to your route:

  1. Open the camelContext.xml file in the src/main/resources/META-INF/spring folder of your simple-route project.

  2. Drag a Choice element (choice icon) from the Routing section of the pallet onto the route1 section of the editor canvas.

    The choice node will show up on the editor canvas.

  3. With the choice node selected, open the context menu.

  4. Select Add|When.

    A when node (when icon), with a connection to the choice node, appears on the canvas and the property editor is configured to edit the when node as shown in Figure 3.1.

  5. Enter /person/city = 'London' into the property editor's Expression field.

    This XPath expression is used to determine which messages will follow this path in the route.

  6. Select xpath from the Language drop down list.

  7. Select the choice node on the canvas.

  8. Select Add|Otherwise from the context menu.

    An otherwise node (otherwise icon), with a connection to the choice node, appears on the canvas. The otherwise node is used to route any messages that are not matched by one of the when nodes.

  9. Click on the first endpoint in the route and drag a connector to the choice node.

    A connector will appear connecting the endpoint with the choice.

  10. Click on the otherwise node and drag a connector the terminal endpoint in the route.

    A connector will appear connecting the otherwise node with the endpoint.

  11. Select the connector between the two endpoints.

  12. Select Edit|Delete to delete the connector.


    The connector's context menu includes a Delete item.

  13. Drag an Endpoint element (endpoint icon) from the pallet into the route square.

  14. Enter file:target/messages/uk in the Uri field.

  15. Click on the when node and drag a connector the new endpoint.

    The route on the canvas should resemble Figure 3.2.

  16. Select File|Save to save the completed route.

  17. Click the Source tab on the bottom of the editor canvas.

    You will see the XML for the route. The camelContext element will look like Example 3.1.

Comments powered by Disqus