Routes define the order and number of modules that process a request. Your app scope can have any number of routes. The dispatcher chooses the route to send a request to based on the endpoint characteristics:
To define a route, create the routeconfig.xml file in the
/project_root/AKZ-INF/config/scope directory of your Akula project. Route configuration files conform to the standard Camel configuration file syntax.
The root tag of the route configuration file is
<routes>. You define each route in a route configuration file with the
<route> child tag.
The following table describes the child tags inside the
Tells the Akula Server to take the request data from the matching request in the endpoint configuration file and send it to a particular module.
The module_prefix is mapped to the module's class used in the route. This prefix does not directly correspond to a module class file. For built-in modules, the Akula Server internally maps the prefix to an actual class. If you create a custom module, you define the mapping of the prefix to the custom module class file.
Akula supports several built-in prefixes, including:
The directive is an optional instruction for the module. Some modules support the directive, while others use it as just a placeholder. Refer to the module's documentation for more information.
In the following example, the prefix is
The route configuration file defines the modules that the route uses in this app scope. The order of the modules defines the order in which the modules are called to transform the request or the current message. The order of the routes in the route configuration file does not matter. Routes are invoked based on the endpoint configuration and are executed as-needed.
The following simple example route configuration file defines two routes:
When the GetSessionRoute is executed, the first module (
direct://GetSessionRoute) is executed. This module converts the request to an AKRequest object. The next module (
akhttp://GetSessionComp) executes. The HTTP module gets data from a REST-based data source and adds it to the body of its output message. The third module (
custom://SortSessionData) then executes, getting the output of the previous module as its input message. This custom module might sort the data that was returned by the second module.
When the last module in the route completes, the output message is sent back to the server so that the payload can be converted to an HTTP response and sent back to the client.
The following example is more complex and contains details about each step in the route. It uses the Convert module to convert data from one type to another as it traverses the route. For more information on the Convert module, see Convert Module.
You can execute multiple routes from a single request. One way to do this is to use configuration files that split the request into multiple messages that are sent to multiple modules, and then aggregate the results of the requests. For information on creating routes that split a single request into multiple requests, see Using Multiple Modules.
You can also execute a second, child route from a single request by using the AKRouteService class in a custom module. This does not allow you to parallel-process multiple requests, but does let you invoke new routes from a module. For more information, see Launching Routes from a Custom Module.