Petals-SE-Camel 1.0.0-SNAPSHOT

Features

The 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.

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 followed by : and then the unique id identifying a service, and optionally an operation to be invoked.

One can refer to provides services with from() and to provides and consumes services with to().
In the case of a provides service called with to(), the message will stay inside the SU and won't go back through Petals.

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

Configuration of a Service Unit to provide a service (JBI)

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

Configuration of a Service Unit to provide a service (CDK)

Parameter Description
Default
Required
timeout Timeout in milliseconds of a synchronous send. This parameter is used by the method sendSync (Exchange exchange) proposes by the CDK Listeners classes.
Set it to 0 for an infinite timeout.
30000 No
exchange-properties This sections defines the list of properties to set to the JBI exchange when processing a service. - No
message-properties This sections defines the list of properties to set to the JBI message when processing a service. - No
validate-wsdl Activate the validation of the WSDL when deploying a service unit. true No
wsdl
Path to the WSDL document describing services and operations exposed by the provided JBI endpoints defined in the SU.
The value of this parameter is :
  • an URL
  • a file relative to the root of the SU package
    If not specified, a basic WSDL description is automaticaly provided by the CDK.
- No
forward-attachments
Defines if attachment will be forwarded from IN message to OUT message.
false No
forward-message-properties
Defines if the message properties will be forwarded from IN message to OUT message. false No
forward-security-subject
Defines if the security subject will be forwarded from IN message to OUT message. false No

Configuration of a Service Unit to provide a service (Camel)

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

Configuration of a Service Unit to consume a service (JBI)

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

Configuration of a Service Unit to consume a service (Camel)

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.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.