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 implement above use case you must first select following dependencies when you are creating a new Ultra project.
Spring JMS Connector from the connector list
Message Transformer, Flow Control, XML Operations, Logging from the processor 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.|
First open the project.xpml file of the project and right click on it (on the XML content of the file). From the context menu, select Resource Template as shown in below figure
After that from the shown dialog box, select ActiveMQ JMS template.
Next you need to specify the required parameters as shown below. It is mandatory to specify a bean prefix and for that you can specify any value. The only other mandatory field is the ActiveMQ Broker URL.
To implement above use case, first create an integration flow named “jms-transaction-flow”, and then add required components by going through following steps in order.
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 JMS Egress Connector. Specify ActiveMq-jmsTemplate as the JMS template and the destination queue name as well.
In the cloned message path add another JMS 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 completed integration flow should look like below.