This section explains, through an example scenario, how the Message Bridge EIP can be implemented using the ESB profile of WSO2 EI. The following topics are covered:
The Messaging Bridge EIP facilitates the connection between messaging systems and replicates messages between them by transforming message formats from one system to the other. For more information, refer to http://www.eaipatterns.com/MessagingBridge.html.
Figure 1: Messaging Bridge EIP
An enterprise might use more than one messaging system in communication. This example illustrates the ESB profile as a message bridge, which accepts a REST message from the client, transforms the REST message to SOAP format, and sends the SOAP message to the back-end Axis2 server. To transform the sent REST request to a SOAP message, we use the API functionality of the ESB profile. It restructures the message to a REST format using the Payload Factory mediator.
The diagram below depicts how to simulate the example scenario using the ESB profile.
Figure 2: Example Scenario of the Messaging Bridge EIP
Before digging into implementation details, let's take a look at the relationship between the example scenario and the Messaging Bridge EIP by comparing their core components.
Messaging Bridge EIP (Figure 1) | Messaging Bridge Example Scenario (Figure 2) |
---|---|
Messaging System1 | Stock Quote client |
Messaging Bridge | PayloadFactory Mediator (You can add any transformation mediator here. Also see Message Translator) |
Messaging System2 | Stock Quote service |
Given below is the ESB configuration of this sample. Log in to the Management Console of the ESB profile, click Main, and then click Source View in the Service Bus menu to view this.
<!-- Message Translator--> <definitions xmlns="http://ws.apache.org/ns/synapse"> <api name="MessageTranslate" context="/stockquote"> <resource methods="GET" uri-template="/view/{symbol}"> <inSequence> <payloadFactory> <format> <m0:getQuote xmlns:m0="http://services.samples"> <m0:request> <m0:symbol>$1</m0:symbol> </m0:request> </m0:getQuote> </format> <args> <arg expression="get-property('uri.var.symbol')"/> </args> </payloadFactory> <property name="SOAPAction" value="getQuote" scope="transport"></property> <send> <endpoint> <address uri="http://localhost:9000/services/SimpleStockQuoteService" format="soap11"/> </endpoint> </send> </inSequence> <outSequence> <send/> </outSequence> </resource> </api> </definitions> |
Let's investigate the elements of the configuration in detail.
Now, let's try out the sample explained above.
curl -v http://127.0.0.1:8280/stockquote/view/IBM
You can use TCPMon to see the type of the message and its message format:
GET /stockquote/view/IBM HTTP/1.1 User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3 Host: 127.0.0.1:8281 Accept: */* |