Version: 17.01
Supported Since: 17.01
The Umbriel Travels Ltd. is a travel agency which arranges accommodations for tourists in South Asia region. The Umbriel Travels exposes an online portal for their customers to book hotels and these booking details are sent to a backend JMS queue from the online portal in a JSON format.
The actual legacy booking services in the backend only accepts XML format messages and emits confirmation messages in XML format as well. Umbriel Travels wants to convert the received JSON messages into XML and vice versa without loosing any messages in between.
Further, they want to send the original JSON message to a another JMS queue for auditing purpose.
Umbriel Travels has decided to integrate the backend booking server through an ESB and delegate the message transformation logic to the ESB. Following diagram depicts the overall architecture of the design. In-order to guarantee that there is no message loss, due to errors in message transformation, JMS transactions have been used. For this implementation, they have decided to use ActiveMQ as the JMS provider.
In-order to develop the above mentioned flow, first you need to add Spring JMS from connector list and regular-transform dependency from processors list.
If you have already created a project, you can add above dependencies via Component Registry. From Tools menu, select Ultra Studio → Component Registry and from the Connectors list and Processors list, select above dependencies |
For this sample let’s use ActiveMQ and if you have not already installed ActiveMQ please follow the installation guide.
You need to add activemq-all
jar into the lib directory of the project. Further, when deploying the project in the UltraESB-X, you need to add the
activemq-all jar into the
lib/custom directory as well.
|
After that, in the project.xpml file select the ActiveMQ JMS template and fill the necessary fields. After that following resources will be added to the project.xpml file
In-order to develop the flow, first let’s create an integration flow named “main-jms-integration” and follow the below steps
Add a JMS Ingress Connector to obtain the request messages in the JMS Format from the source queue. For the connection factory select activeMq-SpringCachingConnectionFactory. Under Transaction tab, select activeMq-ultraTxnmanager as the transaction manager.
Insert a Transaction scope start element to transactionally process the obtained message
Add a Clone Message Processor to clone the received message. For the Exchange pattern specify Keep Original, completion procedure should be On completion of both and specify With full message as the clone type.
In the original Message Path, add a JSON to XML transformer and under root element name specify AddBookingRequest
Next, add a XSD Validator to validate the transformed XML message and select the addBooking.xsd file (in src/resources directory) as the XSD file path
After that send the validated message to destination JMS queue using a Spring JMS Egress Connector. Specify ActiveMq-jmsTemplate as the JMS template and the destination queue name as well.
In the cloned message path add another egress connector to send the JSON message to audit destination
Add a Logger processing element to log the XSD validation failure and specify its properties as below.
After that add an Exception flow end element to exceptionally complete the flow
The complete flow should look as below
Now after running the project, send the sample message to the source queue and it will be sent to the both destination queue.
{
"Currency" : "LKR",
"BookingReference" : "bkp-23-er",
"BookingDepartureDate" : "2017-02-23",
"ItemCity" : "BER",
"Item" : "GER",
"CheckInDate" : "2017-02-25",
"CheckOutDate" : "2017-03-12",
"hotelRooms" : 3,
"ID" : "002:BER:GER:123:456:234"
}
If you remove or change any field, then the XSD validation will fail and message will be rolled back to the original queue without sending it to either of destination queues.
When running the sample in the UltraESB-X distribution, you need to override the following properties in-order for the sample to work.
Refer to Managing Project Properties documentation on how to override properties. |
|
The name of the source queue |
|
The name of the destination queue |
|
The name of the audit queue |
|
Active MQ broker URL (e.g: tcp://localhost:61616) |