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
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...
| 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
|
| 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
|
Interceptor
Example of an interceptor configuration:
<?xml version="1.0" encoding="UTF-8"?> <!--...--> <petalsCDK:su-interceptors> <petalsCDK:send> <petalsCDK:interceptor name="myInterceptorName"> <petalsCDK:param name="myParamName">myParamValue</petalsCDK:param> <petalsCDK:param name="myParamName2">myParamValue2</petalsCDK:param> </petalsCDK:interceptor> </petalsCDK:send> <petalsCDK:accept> <petalsCDK:interceptor name="myInterceptorName"> <petalsCDK:param name="myParamName">myParamValue</petalsCDK:param> </petalsCDK:interceptor> </petalsCDK:accept> <petalsCDK:send-response> <petalsCDK:Interceptor name="myInterceptorName"> <petalsCDK:param name="myParamName">myParamValue</petalsCDK:param> </petalsCDK:Interceptor> </petalsCDK:send-response> <petalsCDK:accept-response> <petalsCDK:Interceptor name="myInterceptorName"> <petalsCDK:param name="myParamName">myParamValue</petalsCDK:param> </petalsCDK:Interceptor> </petalsCDK:accept-response> </petalsCDK:su-interceptors> <!--...-->
Interceptors configuration for SU (CDK)
| Parameter | Description | Default | Required |
|---|---|---|---|
| send | Interceptor dedicated to send phase, for an exchange sent by a consumer | - | No |
| accept | Interceptor dedicated to receive phase, for an exchange received by a provider | - | No |
| send-response | Interceptor dedicated to send phase, for an exchange (a response) received by a consumer | - | No |
| accept-response | Interceptor dedicated to receive phase, for an exchange sent (a response) by a provider | - | No |
| interceptor - name | Logical name of the interceptor instance. It can be referenced to add extended parameters by a SU Interceptor configuration. | - | Yes |
| param[] - name | The name of the parameter to use for the interceptor for this SU | - | No |
| param[] | The value of the parameter to use for the interceptor for this SU | - | No |