DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Securing Your Software Supply Chain with JFrog and Azure
Register Today

Trending

  • Essential Architecture Framework: In the World of Overengineering, Being Essential Is the Answer
  • A React Frontend With Go/Gin/Gorm Backend in One Project
  • What Is Envoy Proxy?
  • Cucumber Selenium Tutorial: A Comprehensive Guide With Examples and Best Practices

Trending

  • Essential Architecture Framework: In the World of Overengineering, Being Essential Is the Answer
  • A React Frontend With Go/Gin/Gorm Backend in One Project
  • What Is Envoy Proxy?
  • Cucumber Selenium Tutorial: A Comprehensive Guide With Examples and Best Practices
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. WSO2 ESB Cloning and Aggregating With Train Sample

WSO2 ESB Cloning and Aggregating With Train Sample

Eric Genesky user avatar by
Eric Genesky
·
Jun. 14, 13 · Interview
Like (1)
Save
Tweet
Share
7.91K Views

Join the DZone community and get the full member experience.

Join For Free

In Europe there are some many places to visit and trains will be best way to move rather than flying if you wish to enjoy surroundings. But when you search for train from one country city to another Europe county city results are not much powerful for guest expectations. Lot of time it give result as

" Sorry, but we couldn’t find any results for your search" in red letters.

But fine for master cities. But in here I am not going talk about Trains or Europe.

Let go to technical (IT) world or SOA perspective. Each Train Services provider will have and interface where they expose their services . Such as when user request destination with particular start point he/she will get trains on that path with price and duration in hours. (Plus Leaving time from starting location)

image

Here I have service for demo with wso2 Data services with MySQL. Here is services from Thalys.

Here is data Services for TVG

<data name="TGV">

<config id="mysql1">

<property name="driverClassName">com.mysql.jdbc.Driver</property>

<property name="url">jdbc:mysql://localhost:3306/trains</property>

<property name="username">root</property>

<property name="password">root</property>

</config>

<query id="getTVGTrains" useConfig="mysql1">

<sql>SELECT StartingLocation, EndingLocation, TourDuration, TicketPrice, TrainsName, LeavingTime FROM `trains` WHERE `TrainsName` LIKE '%TVG%' AND StartingLocation = :StartingLocation AND EndingLocation = :EndingLocation</sql>

<result element="Entries" rowName="Entry">

<element column="StartingLocation" name="StartingLocation" xsdType="string"/>

<element column="EndingLocation" name="EndingLocation" xsdType="string"/>

<element column="TourDuration" name="TourDuration" xsdType="string"/>

<element column="TicketPrice" name="TicketPrice" xsdType="string"/>

<element column="TrainsName" name="TrainsName" xsdType="string"/>

<element column="LeavingTime" name="LeavingTime" xsdType="string"/>

</result>

<param name="StartingLocation" sqlType="STRING"/>

<param name="EndingLocation" sqlType="STRING"/>

</query>

<operation name="getTrains">

<call-query href="getTVGTrains">

<with-param name="StartingLocation" query-param="StartingLocation"/>

<with-param name="EndingLocation" query-param="EndingLocation"/>

</call-query>

</operation>

</data>

Now create same to other also

Here is sample Web request

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dat="http://ws.wso2.org/dataservice"> 
   <soapenv:Header/> 
   <soapenv:Body> 
      <dat:getTrains> 
         <dat:StartingLocation>Turin</dat:StartingLocation> 
         <dat:EndingLocation>Paris</dat:EndingLocation> 
      </dat:getTrains> 
   </soapenv:Body> 
</soapenv:Envelope>

Sample respond

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
   <soapenv:Body> 
      <Entries xmlns="http://ws.wso2.org/dataservice"> 
         <Entry> 
            <StartingLocation>Turin</StartingLocation> 
            <EndingLocation>Paris</EndingLocation> 
            <TourDuration>5:30 hours</TourDuration> 
            <TicketPrice>150</TicketPrice> 
            <TrainsName>TVG-2302</TrainsName> 
            <LeavingTime>8.30AM</LeavingTime> 
         </Entry> 
         <Entry> 
            <StartingLocation>Turin</StartingLocation> 
            <EndingLocation>Paris</EndingLocation> 
            <TourDuration>4:30 hours</TourDuration> 
            <TicketPrice>150</TicketPrice> 
            <TrainsName>TVG-3444</TrainsName> 
            <LeavingTime>10.00AM</LeavingTime> 
         </Entry> 
      </Entries> 
   </soapenv:Body> 
</soapenv:Envelope>

Then ESB for Proxy For Cloning and aggregating (If respond and different then use XSLT mediator for informing those in to one formation)

<proxy xmlns="http://ws.apache.org/ns/synapse" name="AllEuropTrains" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">

<target>

<inSequence>

<clone>

<target>

<endpoint name="TGV">

<address uri="http://localhost:9764/services/TGV/"/>

</endpoint>

</target>

<target>

<endpoint name="EUROStar">

<address uri="http://localhost:9764/services/EUROStar/"/>

</endpoint>

</target>

<target>

<endpoint name="THYLYS">

<address uri="http://localhost:9764/services/THYLYS/"/>

</endpoint>

</target>

</clone>

</inSequence>

<outSequence>

<aggregate>

<completeCondition>

<messageCount min="-1" max="-1"/>

</completeCondition>

<onComplete xmlns:m0="http://ws.wso2.org/dataservice" expression="//m0:Entries">

<log level="custom" separator=",">

<property name="MessageFlow" value="======================= Sending Back the Aggregated Responses. ==============="/>

</log>

<log level="full" separator=","/>

<enrich>

<source xmlns:m1="http://ws.wso2.org/dataservice" clone="true" xpath="//m1:Entries/m1:Entry"/>

<target type="body" action="child"/>

</enrich>

<send/>

</onComplete>

</aggregate>

</outSequence>

</target>

<publishWSDL key="conf:/blog/train/AllTrain.wsdl"/>

<description></description>

</proxy>

Then Try out the proxy from here you will see all respond in one message


image

Time to enjoy joying more services with Clone and Aggregate.


Enterprise service bus Cloning

Published at DZone with permission of Eric Genesky. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • Essential Architecture Framework: In the World of Overengineering, Being Essential Is the Answer
  • A React Frontend With Go/Gin/Gorm Backend in One Project
  • What Is Envoy Proxy?
  • Cucumber Selenium Tutorial: A Comprehensive Guide With Examples and Best Practices

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: