Petals-SE-Camel 1.3.0+

compared with
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (36)

View Page History
{multi-excerpt-include:Petals-SE-Camel|name=features|nopanel=true}

{warning}This version must be installed on [Petals ESB 5.2.0|petalsesb520:Petals 5.3.0|petalsesb530:Petals ESB 5.23.0]+{warning}
{column}

h3. Service provider configuration

h4. Configuration at CDK level
All needed information must be defined in the service-unit JBI descriptor. This JBI descriptor is configured through parameters divided in following groups:
* *JBI parameters* that defines the service provider identification,
* *CDK parameters* that are parameters driving the service provider implementation at CDK layer,
* *CDK interceptor parameters* that are parameters driving interceptors at CDK layer,
* *Dedicated parameters* that are parameters driving the service provider implementation at component layer.

h3. CDK parameters defining service provider implementation
The following parameters correspond to the CDK configuration of the service provider implementation.

{include:0 CDK SU Provide Configuration 5.8.0}

h4. Specific configuration
h3. CDK parameters driving interceptors
The following parameters drive interceptors at CDK layer.

{include:0 CDK SU Interceptor configuration 5.8.0}

h3. Dedicated configuration

No specific configuration exists.


When an exchange is sent from Camel to Petals through a consumes endpoint, the following happen:
* The Camel exchange is transformed to a JBI exchange.
* Its properties prefixed by "PetalsProperty." are put (by reference) into the JBI exchange properties (without the prefix).
* Its "In" message is transformed to a normalized message.
* Its headers are put into the normalized exchange properties (by reference).
* Its attachments are put into the normalized message attachments (by reference).
* The body is transformed, using available [Camel type converters|http://camel.apache.org/type-converter.html], to a DOMSource object (or if it is already a Source, it stays as a Source) and put in the content of the normalized message.

The Camel exchange is transformed to a JBI exchange.
Its properties prefixed by "PetalsProperty." are put (by reference) into the JBI exchange properties (without the prefix).
Its In message is transformed to a normalized message.
Its headers are put into the normalized exchange properties (by reference).
Its attachments are put into the normalized message attachments (by reference).
The body is transformed, using available [Camel type converters|http://camel.apache.org/type-converter.html], to a DOMSource object (or if it is already a Source, it stays as a Source) and put in the content of the normalized message.
The Camel's endpoint "*to*" is defined through an identifier ('{{service-id}}') refering to a service consumer definition in the service unit JBI descriptor.

h2. Back to Camel from Petals
h3. Specifying the service consumer

When an answer to an exchange sent to Petals arrives back to Camel through a consumes endpoint, the following happen:
The definition of the service consumer is declared in the service unit JBI descriptor, in a section "consumes".

The Camel exchange properties prefixed by "PetalsProperty." are updated from the JBI exchange properties (by reference).
If the exchange has the error status, the exception is put in the exchange.
If the exchange has a Fault, it is transformed to a Camel message (same process as before), the fault status is set on it and put as the exchange's Out.
If the exchange has an Out, it is transformed to a Camel message (same process as before) and put as the exchange's Out.
All needed information must be defined in the service-unit JBI descriptor. This JBI descriptor is configured through parameters divided in following groups:
* *JBI parameters* that defines the service provider identification,
* *CDK parameters* that are parameters driving the service provider implementation at CDK layer,
* *CDK interceptor parameters* that are parameters driving interceptors at CDK layer,
* *Dedicated parameters* that are parameters driving the service provider implementation at component layer.

h2. Back to Petals from Camel
h4. CDK parameters defining service provider implementation
The following parameters correspond to the CDK configuration of the service consumer implementation.

When an answer to an exchange sent to Camel from Petals arrives back to Petals through a provides endpoint, the following happen:
{include:0 CDK SU SE Consume Configuration 5.8.0}

The JBI exchange properties are updated (by reference) with the Camel exchange properties prefixed by "PetalsOriginalProperty." (without the prefix).
If the exchange has an Exception, the exception is put as the JBI exchange's error and its status is set to error.
If the exchange has a Fault, it is transformed to a normalized message of type fault (same process as before) and put as the JBI exchange's Fault.
If the exchange has an Out and it is an InOut or an InOptionalOut, it is transformed to a normalized message (same process as before) and put as the JBI exchange's Out.
If the exchange has no Out and it is an InOut exchange, its In message is transformed to a normalized message (same process as before) and put as the JBI exchange's Out.
In all the other cases, the exchange's status is changed to done.
h4. CDK parameters driving interceptors
The following parameters drive interceptors at CDK layer.

{warning}
Some Camel processors are made to work in-place with an In message without making an Out message: because of this practice (see http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html), we have to make the assumption that an InOptionalOut Camel message MUST have an Out message for the exchange to be considered not done!
In other words: before sending an InOptionalOut message that has an Out message back to Petals, make sure that the answer is not in the In but in the Out message of the Camel exchange.
{warning}
{include:0 CDK SU Interceptor configuration 5.8.0}

h1. Specifying service name, endpoint name, operation name, MEP and headers of a to() in the Camel route
h4. Dedicated configuration

When defining Consumes in the jbi.xml, it is not mandatory to specify the service name and endpoint name, but actually neither the operation and mep.
{table-plus}
|| Parameter || Description || Default || Required ||
| service-id | The reference of the service consumer. This value is used, prefixed with '{{petals:}}', in the Camel route's endpoint "*to*". | {center}\-{center} | {center}Yes{center} |
{table-plus}

Concerning the service, the endpoint and the operation names, they are not mandatory elements to be set on a Petals exchange.
Inversely, the MEP should always be specified on a Petals exchange.
h4. Override parameters of the service consumer directly from the Camel's route

{include:0 CDK SU SE Consume Configuration 5.8.0}

h2. Specifying parameters on the endpoint URI

One way to influence the service, endpoint, operation names and the MEP is to set parameters on the endpoint URI in the Camel route like this:

* endpointName can only be set if either the Consumes or the endpoint URI have a serviceName set

h24. Using the MEP of the Camel exchange

Even though it's not the most recommended (because of its implicit nature), if no MEP is set neither on the Consumes or the Camel endpoint URI, then the MEP of the Camel exchange will be used.

h2. Back to Camel from Petals

When an answer to an exchange sent to Petals arrives back to Camel through a consumes endpoint, the following happen:
* The Camel exchange properties prefixed by "*PetalsProperty.*" are updated from the JBI exchange properties (by reference).
* If the exchange has the *error* status, the exception is put in the exchange.
* If the exchange has a *Fault*, it is transformed to a Camel message (same process as before), the fault status is set on it and put as the exchange's Out.
* If the exchange has an *Out*, it is transformed to a Camel message (same process as before) and put as the exchange's Out.

h2. Back to Petals from Camel

When an answer to an exchange sent to Camel from Petals arrives back to Petals through a provides endpoint, the following happen:
* The JBI exchange properties are updated (by reference) with the Camel exchange properties prefixed by "*PetalsOriginalProperty*." (without the prefix).
* If the exchange has an *Exception*, the exception is put as the JBI exchange's error and its status is set to "*error*".
* If the exchange has a *Fault*, it is transformed to a normalized message of type "*fault*" (same process as before) and put as the JBI exchange's Fault.
* If the exchange has an "*Out*" and it is an "*InOut*" or an "*InOptionalOut*", it is transformed to a normalized message (same process as before) and put as the JBI exchange's Out.
* If the exchange has no "*Out*" and it is an "*InOut*" exchange, its In message is transformed to a normalized message (same process as before) and put as the JBI exchange's Out.
* In all the other cases, the exchange's status is changed to done.

{warning}
Some Camel processors are made to work in-place with an "*In*" message without making an "*Out*" message: because of this practice (see http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html), we have to make the assumption that an "*InOptionalOut*" Camel message MUST have an "*Out*" message for the exchange to be considered not done!
In other words: before sending an "*InOptionalOut*" message that has an "*Out*" message back to Petals, make sure that the answer is not in the "*In*" but in the "*Out*" message of the Camel exchange.
{warning}

h1. Manipulating JBI faults in a Camel route

Apache Camel does not support advanced manipulation of faults through their {{Exchange}}/{{Message}} API:
* if a message is marked as being a fault (via {{Message.isFault}}), it won't be possible in a Camel route to process it as a normal message.
* The route will simply stop its processing.
* This is because Camel does not encourage a WSDL-oriented paradigm of defining exchanges like JBI do.

Hence, the Camel SE introduces some helpers (in {{camel-petals}}'s {{PetalsRouteBuilder}}) to reand and mark messages as faults outside of the facilities provided by Camel.