Adding routes to the routing context

Overview

The camelContext element within an XML context file creates a routing context. The camelContext element can contain one or more routes, and each route displayed on the canvas, as a Route container node, maps to a route element in the generated camelContext element.

When you create a new Fuse Project, the Camel tooling creates an example camelContext.xml file that is defined either as camel-context.xml (Spring) or blueprint.xml (Blueprint). You can view and edit the contents of the camelContext.xml file in the route editor's Source view. In Design view, the route editor displays a Route container node, which represents the empty route element. You can drag patterns from the Palette and drop them into the Route container node on the canvas to create a route. The Camel tooling updates the empty route element with XML code generated from the patterns you dropped into the Route container node on the canvas.

The tooling provides two methods for adding a new route:

  • In Design view, by dragging a Route pattern from the Palette's Routing drawer and dropping it onto the canvas

  • In Source view, by adding a <route/> element to the existing list within the camelContext element

Procedure

To add another route to the camelContext: element

  1. Select one of the methods for adding a route.

    In Design view, the Properties editor displays the list of the new route's properties for you to edit.

  2. In the Properties editor, enter :

    • An ID (for example, Route2) for the new route in the route's Id field

    • A description of the route in the Description field

    • A value for any other property as needed

  3. On the menu bar, select File > Save to save the changes you made to the routing context file.

[Note]Note

To switch between multiple routes, select the route you want to display on the canvas by clicking its entry under the project's Camel Contexts folder in Project Explorer.

When you click the context file entry in Project Explorer, the canvas displays all routes in the context, as space allows.

Related topics

Red Hat JBoss Fuse Tooling Tutorials, To Add a Content-Based Router
Red Hat JBoss Fuse Tooling Tutorials, To Add Another Route to the CBR Routing Context