route keyword
(Back to
Integration Flow Language Specification)
Child Keywords
Basic syntax
Is to declare a route code block as an IFL roote element (not nested in another route):
route do
from "<logical service name 1>" # occurs once
to "<logical service name 2>" # occurs 0 or more times
end
Alternate simplified syntax
When only one "from" and "to" is used:
route from "<logical service name 1>" to "<logical service name 2>"
route With Composite Constructs
Instead of the simple "to" of the pipe-and-filter pattern, the other EIP keywords can be inserted. For example adding a broadcast to the route:
route do
from "<logical service name 1>" # occurs at most once
to "<logical service naem 2>" # occurs 0 or more times
broadcast do # occurs at most once within an enclosing route
route to "<logical service name 3>" # occurs 0 or more times
route to "<logical service name 4>" # occurs 0 or more times
end
end
Note that for route used nested inside a broadcast (and in turn top level route) there is an implicit "from" as the message is piped from the preceding keyword and no "from" declaration is used:
Nexted route:
...
route do
to "<logical service name 2>" # occurs 0 or more times
end
...
Named route
Routes can be named so they can be called and included in other routes. It can be thought of as defining a re-usable endpoint, breaking the routing up into re-usable pieces. Named routes do not have a "from", implicitly messages come from routing messages to that route name/endpoint.
route "<my-route-name>" do
to "<logical filter name 1>" # occurs 0 or more times
to "<logical service name>" # occurs once
end
The named route "endpoint" can be referenced in the other IFL construct like any other service, i.e. to call the above one or more other routes could state (assuming a name of my-route-name):
route do
from "my-trasnport"
to "some-transform"
to "my-route-name"
end
Scenarios:
One "from", one "to"
Defines the concrete routing of a message fom a calling service (sometimes termed an endpoint reference, a logical name the consumer of a service uses) to the implementing / provisioning service.
Example: an RSS service routes any new entries to an instant messaging server
route do
from "cnnnewsfeed"
to "IM"
end
One "from", two or more "to"
This declares the classic pipe and filter pattern; output from the preceding service (whether "from" or previous "to") it piped to the input of the next "to"
Example: an RSS service routes any new entries to filter implemented in JRuby, the output of the filter is routed to an instant messaging server
route do
from "cnnnewsfeed"
to "jrubyfilter"
to "IM"
end
One "from", one or more composite constructs such as "broadcast":
Defines the concrete routing of a message fom a calling service (sometimes termed an endpoint reference, a logical name the consumer of a service uses) to the enterprise integration pattern implemented by the composite construct (e.g. "broadcast"), which then routes to the implementing / provisioning service(s).
Example: an RSS service routes any new entries to a broadcast enterpise integration pattern (composite construct), which sends a copy each in parallel to multiple services; in this case both to an instant messaging server and a file archive
route do
from "cnnnewsfeed"
broadcast do
route to "IM"
route to "filearchive"
end
end