FeaturesThe component SE Camel embeds the Apache Camel routing engine to execute enterprise integration patterns (EIP) in Petals. Service Units can be written to describe, for a given provided Petals endpoint, how and where messages should be routed. Even if it is recommended to route messages toward other Petals services, it is still always possible to exploit Camel transports to integrate with non-Petals external services. |
Table of contents Contributors
No contributors found for: authors on selected page(s)
|
Introduction
This implementation of the SE Camel uses Camel version 2.14.X.
Routes can be defined using any of the JVM based DSL, as well as using the XML notation.
For each provides section, one or many routes can be activated when a message is received.
Each route can call any service declared in a consumes section.
The terminology used by Camel is apparently counter-intuitive to the one used in JBI terminology: a camel route consumes a service while an SU provides this same service. This is because from the route point of view, messages arriving to the provided service are then consumed by the rule. |
We show in the next section a general overview of a typical Service Unit.
Overview of a Camel Service Unit at Implementation Time
Service Unit Content
A Camel SU typically contains the following elements:
su-camel-ServiceName-provide.zip + META-INF - jbi.xml + service.wsdl (one or several) + route-implementation.jar (none, one or several) + route-implementation.xml (none, one or several)
There must be at least one route implementation, in a jar file or an xml file ; a WSDL description for every service declared in the JBI descriptor and of course a JBI descriptor.
A Camel Route
Here is an example of a Camel route defined in XML:
<route id="NormalizeMessageData"> <from uri="petals:incomingOrders" /> <convertBodyTo type="java.lang.String" /> <choice> <when> <simple>${body} contains '?xml'</simple> <unmarshal> <jaxb contextPath="org.fusesource.camel" /> </unmarshal> <to uri="petals:orders" /> </when> <otherwise> <unmarshal> <bindy packages="org.fusesource.camel" type="Csv" /> </unmarshal> <to uri="petals:orders2" /> </otherwise> </choice> </route>
TODO. make that a real example, this is copied from an example on the web...
The only specificity of this route are the URIs used to identify the services consumed by the route (from element) and to which messages are then sent (to element).
The protocol reserved to petals is petals and it is then followed by a unique id from the JBI description as explained next.
JBI Descriptor
The JBI descriptor contains:
- The services that are provided by this SU and for which routes will handle messages, and
- The services consumed by this SU and that will be callable from the route.
In order to identify a service, each of the, provided or consumed, service must have a unique id.
Of course, a provided service will be only usable by from elements and consumed services by to elements.
<?xml version="1.0" encoding="UTF-8"?> <jbi:jbi version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jbi="http://java.sun.com/xml/ns/jbi" xmlns:petalsCDK="http://petals.ow2.org/components/extensions/version-5" xmlns:helloworld="http://petals.ow2.org/helloworld" xmlns:camel="http://petals.ow2.org/components/camel/version-1"> <jbi:services binding-component="false"> <jbi:provides interface-name="helloworld:Helloworld" service-name="helloworld:HelloworldService" endpoint-name="HelloworldEndpoint"> <petalsCDK:wsdl>service.wsdl</petalsCDK:wsdl> <camel:service-id>incomingOrders</camel:class> </jbi:provides> <jbi:consumes interface-name="sample:calledInterface1" service-name="sample:calledService1" endpoint-name="calledEndpoint1"> <camel:service-id>orders</camel:class> </jbi:consumes> <jbi:consumes interface-name="sample:calledInterface2" service-name="sample:calledService2" endpoint-name="calledEndpoint2"> <camel:service-id>orders2</camel:class> </jbi:consumes> <camel:routes> <camel:xml-route>route-implementation.xml</camel:xml-route> <camel:jvm-route>org.example.RouteImplementation</camel:jvm-route> <camel:jvm-route>org.example.RouteImplementation2</camel:jvm-route> </camel:routes> </jbi:services> </jbi:jbi>
TODO. make that a real example, this is copied from jsi181 with bits of EIP and a mock-up for camel:routes...
Provides Section
Parameter | Description |
Default |
Required |
---|---|---|---|
provides | Describe the JBI service that will be exposed into the JBI bus. Interface (QName), Service (QName) and Endpoint (String) attributes are required. | - | Yes |
Parameter | Description | Default | Required |
---|---|---|---|
service-id | The unique id in the SU for the provided service. It will be visible from the route to refer to this service. | -
|
Yes
|
Consumes Section
Parameter | Description | Default | Required |
---|---|---|---|
consumes | Refer JBI service to invoke into the JBI bus. You can define an explicit endpoint: interface (QName) / Service (QName) / Endpoint (String) attributes Or define implicit endpoint, to let the container routing according to QOS configurations (HA...): -by Interface attribute (QName); -by Service attribute (QName). |
- | Yes |
Parameter | Description | Default | Required |
---|---|---|---|
service-id | The unique id in the SU for the consumed service. It will be visible from the route to refer to this service. | -
|
Yes
|
Services Section
TODO. Not sure this should be in the service section... this seems to be the natural place for it to be because it is not bound to a specific service but to the whole SU...
TODO. Is there an include also with a table for the whole services section?
Overview of a Camel Service Unit at Runtime
Camel routes are instantiated in a Camel context.
With the SE Camel, for every SU, there is one Camel context created containing all the routes described in the SU.
When a message arrives on a provided service, it is dispatched to all the routes that consumes the service.
There is no guarantee of order of the route executed nor guarantee of either parallel or sequential execution of the routes.
TODO. This is of course open to discussion.