View Source

Hi \! Today is you last day. You will create a simple process: bufferize messages, and execute all of them in one time with _MathOperations_. You will use EIP chains for this.


{panel:title=Last tested with}
* Petals Guide Package 1.0 - [Download binaries here|http://doc.petalslink.com/x/t4KK]
* Tomcat 6.0.29
* JDK 6 update 20

This Tutorial uses:
* Petals Studio
* Petals ESB
* Petals SE RMI
* Petals BC SOAP
* Petals Web console
* Tomcat
* Petals SE Jsr-181
* Petals SE EIP _(new)_
{panel}
{info}This tutorial is based on the use case: [petalscomponents:Bufferize operations with EIP].
{info}
Any question, any problem? Check the [discussions on EIP tutorial|http://forum.petalslink.com/Petals-Starting-Guide-day-5-EIP-td2688060.html] to find a solution. 

h2. Integration process definition

You will use Enterprise Integration Patterns (EIP, see below for explanations) to create this process:
* Several messages are sent to an *EIPAggregator* pattern, which bufferizes all the incoming messages.
* A trigger message is sent to *EipAggregator.*
* The *EipAggregator* sends an aggregated message to *EipSPlitter*.
* The *EipSplitter* splits the aggregated message back into multiple messages.
* The *EipSPlitter* sends the multiple messages to the operation *AddIntegers* of the *MathOperations service.*
* The *MathOperations.AddIntegers* operation processes the messages and sends the responses.

{gliffy:space=petalscomponents|page=Bufferize operations with EIP|name=Petals RMI-EIP-JSR181}

*What is EIP ?*
A set of design patterns for enterprise application integration.

*What is Agregator pattern ?*
*What is Splitter Pattern ?*
Read [EIP Aggregator|http://doc.petalslink.com/display/petalscomponents/Petals-SE-EIP+2.5#Petals-SE-EIP2.5-AggregatorPattern] and [EIP SPlitter|http://doc.petalslink.com/display/petalscomponents/Petals-SE-EIP+2.5#Petals-SE-EIP2.5-SplitterPattern] documentation to understand those patterns.

h2. Configure EIP Splitter

# Launch *Petals Studio*.
# Click *File > New > Service-Unit Project*.
# Select *Use a Petals technical Service > EIP > Your_EIP_Version*.
# Configure Splitter Service-Unit with following configuration:
|| Parameter name \\ || Value \\ ||
|| JBI properties || _Note: EIP does not need a WSDL_ \\ ||
| Interface namespace: | [http://test.petalslink.com] |
| InterfaceName: | EipSplitterInterface |
| Service Namespace: | [http://test.petalslink.com] |
| Service Name: | EipSplitter |
| End-point Name: | EipSplitterEndpoint |
|| Project Name and Location || ||
| Project Name: | su-EIP-EipSplitter-provide |
|| Chain calls (1) || ||
| Eip: | Splitter |
|| Chain calls (2) \\ || ||
| Selected Pattern: splitter | see below for configuration |
# Click *Add > Edit*. It displays the window "EIP: Invoked Service 1".
# Click *Select a service*.
# Double click *MathOperations implements MathOperations @ MathOperationsPort*.
# Fill the following properties for *Invoked Service 1*:
|| Service Identifiers || _auto-configured_ ||
|| Invocation Properties || ||
| Operation Namespace: | [http://test.petalslink.com] |
| Operation: | AddIntegers |
| Mep: | InOut |
|| Routing Condition || ||
| XPath Condition | //*\[local-name()="AddIntegers"\] |
# Click *Ok > Next > Finish*.

h2. Configure EIP Aggregator

# Create another *New Service-Unit Project* for *EIP Technical Service* with the following configuration:
|| Parameter name \\ || Value \\ ||
|| JBI propertie || ||
| Interface Namespace: | [http://test.petalslink.com] |
| Interface Name: | EipAggregatorInterface |
| Service Namespace: | [http://test.petalslink.com] |
| Service Name: | EipAggregator |
| End-point Name: | EipAggregatorEndpoint |
|| Project Name and Location || ||
| Project Name: | su-EIP-EipAggregator-provide |
|| Chain calls (1) || ||
| Eip: | Aggregator |
| Aggregator Correlation: | boolean(/*\[local-name()="AddIntegers"\]) |
|| Chain calls (2) || ||
| Selected Pattern: aggregator | see below for configuration |
# Click *Add > Edit*. It displays the window "EIP: Invoked Service 1".
# Click *Select a service*.
# Double click *EipSplitter implements EipSplitterInterface @ EipSplitterEndpoint*.
# Fill the following properties for *Invoked Service 1*:
|| Service Identifiers || _auto-configured_ ||
|| Invocation Properties || ||
| Operation Namespace: | [http://test.petalslink.com|http://test.petalslink.com/] |
| Operation: | AddIntegers |
| Mep: | InOut |
|| Routing Condition || ||
| XPath Condition | {noformat:nopanel=true}boolean(/*[local-name()="AddIntegers"]/*[local-name()="equals"]){noformat} |
# Click *Ok > Next > Finish*.

h2. Create and deploy an EIP Service Assembly

Beacause EipSplitter and EipAggregator are tight-coupled, they can be packaged in one Service Assembly, without loosing felxibility. This is especially adapted with EIP, which can chain lots of EIP Service-Units.
# Click *File > New > Service Assembly Project*.
|| Service Assembly || ||
| Name: | sa-Eip-AggregatorSplitter |
| Artifact ID: | sa-Eip-AggregatorSplitter |
# Click *Next*.
# Check *su-EIP-EipSplitter-provide* and *su-EIP-EipAggregator-provide*.
# Click *Finish*.
# *Fast-export* the Service Assembly for Petals.
# [Download|http://doc.petalslink.com/x/t4KK] Petals-SE-EIP.
# Deploy Petals-SE-EIP in Petals ESB.
# Deploy sa-Eip-AggregatorSplitter in Petals ESB.


h2. Understand XPath expressions

*What is XPath ?*
Run this tutorial (takes \~30 min) for Xpath : [http://www.w3schools.com/XPath/default.asp|http://www.w3schools.com/XPath/default.asp]
Look at XPath expressions used in EipSplitter and EipAggregator. Try to understand them. XPath is essential to use Petals-SE-EIP.

*EIP Agregator conditions:*
# Elements which satisfy "aggregator-correlation" are aggregated
{code:lang=xml}<eip:aggregator-correlation>boolean(/*[local-name()="AddIntegers"])</eip:aggregator-correlation>{code}
Elements inside <AddIntegers> will be aggregated.
# When "test" is true, aggregated message is sent.
{code:lang=xml}<eip:test>boolean(/*[local-name()="AddIntegers"]/*[local-name()="equals"])</eip:test>{code}
When <AddIntegers> contains the <equals> element, the aggregated message is sent to the next service, and buffer cleared.

*EIP Splitter conditions:*
# Elements which satisfy "test" are extracted and sent to the next service.
{code:lang=xml}<eip:test>//*[local-name()="AddIntegers"]</eip:test>{code}
<AddIntegers> elements are split and sent one by one.

h2. Test the EIP chain

# Check that sa-jsr181-MathOperations-provide (from last day tutorial) is deployed in Petals ESB. If not, deploy it.
# Deploy sa-Eip-AggregatorSplitter in Petals ESB.
# Go to *Webconsole > Server: 0 > Test > Send*
# Send following messages to *Endpoint* EipAggregatorEndpoint, with *MEP* InOut:
{code:lang=xml|title=Message 1}
<AddIntegers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<integer1>1</integer1>
<integer2>2</integer2>
</AddIntegers>
{code}
{code:lang=xml|title=Response message|theme=Default}
<result xmlns="http://petals.ow2.org/petals-se-eip/aggregator">Aggregator: the content is buffered by the pattern</result>
{code}
{code:lang=xml|title=Message 2}
<AddIntegers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<integer1>3</integer1>
<integer2>4</integer2>
</AddIntegers>
{code}
{code:lang=xml|title=Message 3}
<AddIntegers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<integer1>5</integer1>
<integer2>6</integer2>
</AddIntegers>
{code}
# Send trigger message:
{code:lang=xml|title=Message 4 - Trigger}
<AddIntegers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<equals/>
</AddIntegers>
{code}
{code:lang=xml|title=Response message|theme=Default}
<result xmlns="http://petals.ow2.org/petals-se-eip/splitter">
<dlwmin:AddIntegersResponse xmlns:dlwmin="http://test.petalslink.com" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<returnMessage xmlns="">3</returnMessage>
</dlwmin:AddIntegersResponse>
<dlwmin:AddIntegersResponse xmlns:dlwmin="http://test.petalslink.com" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<returnMessage xmlns="">7</returnMessage>
</dlwmin:AddIntegersResponse>
<dlwmin:AddIntegersResponse xmlns:dlwmin="http://test.petalslink.com" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<returnMessage xmlns="">11</returnMessage>
</dlwmin:AddIntegersResponse>
</result>
{code}

h2. More about orchestration







*Orchestration alternatives:*

You can orchestrate services in Petals with either BPEL, SCA, JSR181, EIP or POJO. Read this *[Orchestration Whitepaper|http://www.petalslink.com/fr/forms/orchestration-de-processus-quelle-technologie-privilegier]* to learn more.

Main differences between orchestration technologies:
- EIP: Good performances. But complicated and best-suited for integration projects than SOA (WSDL are not required).
- BPEL: Based on XML and WSDL. Standard. Requires some time to be mastered.
- SCA: Another approach of orchestration. Java code, based on WSDL and dependency injections offered by the SCA Java specification.
- POJO or JSR181: Needs advanced Java programmation.
- Custom JBI Component: Need of programming skills with Java. Best performances. Hard to maintain. Not mandatory a good practice.

*Finished \!*
*Bravo, you successfully ran the Petals Getting Started Guide.*

Want to know more ?
- Tell me what additional tutorial you would like.
- Ask for advises and help on [the forum|http://forum.petalslink.com].
- Trainings gives advanced knowledge on Petals ESB. They talk more about SOA, and real project problems.

For all this, just contact me\!
mathieu.lebreton@petalslink.com