This section explains, through an example scenario, how the Document Message EIP can be implemented using WSO2 ESB. The following topics are covered:
Introduction to Document Message
The Document Message EIP is used to reliably transfer a data structure between applications. The Command Message EIP allows you to invoke only a specific client through the ESB, while the Document Message EIP sends the entire data unit to the receiver. For more information, refer to http://www.eaipatterns.com/DocumentMessage.html.
Figure 1: Document Message EIP
Example scenario
This example demonstrates WSO2 ESB transmitting an entire message from a client to a sample Axis2 server as a document message, which the Axis2 server processes so it can identify which operation to invoke.
The diagram below depicts how to simulate the example scenario using the WSO2 ESB.
Figure 2: Example Scenario of the Document Message EIP
Before digging into implementation details, let's take a look at the relationship between the example scenario and the Document Message EIP by comparing their core components.
Document Message EIP (Figure 1) | Document Message Example Scenario (Figure 2) |
---|---|
Sender | Stock Quote Client |
Document Message | Proxy Service |
Receiver | Simple Stock Quote Service Instance |
Environment setup
- Download and install WSO2 ESB from http://wso2.com/products/enterprise-service-bus. For a list of prerequisites and step-by-step installation instructions, refer to Installation Guide in the WSO2 ESB documentation.
- Start the sample Axis2 server. For instructions, refer to the section Setting Up the ESB Samples - Starting the Axis2 server in the WSO2 ESB documentation.
ESB Configuration
Start the ESB server and log into its management console UI (https:
//localhost:9443/carbon
). In the management console, navigate to the Main menu and click Source View in the Service Bus section. Next, copy and paste the following configuration, which helps you explore the example scenario, to the source view.
<?xml version="1.0" encoding="UTF-8"?> <definitions xmlns="http://ws.apache.org/ns/synapse"> <proxy name="DocumentMessageProxy" transports="https http" startOnLoad="true" trace="disable"> <target> <inSequence> <send> <endpoint> <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> </endpoint> </send> </inSequence> <outSequence> <send/> </outSequence> </target> </proxy> <sequence name="fault"> <log level="full"> <property name="MESSAGE" value="Executing default "fault" sequence"/> <property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/> <property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/> </log> <drop/> </sequence> <sequence name="main"> <log/> <send/> </sequence> </definitions>
Simulating the sample scenario
Using a SOAP client (such as SoapUI), send a request to the ESB server to invoke the DocumentMessageProxy
. Note that the entire request will be passed to the back-end Axis2 Server, and the client will receive the response in return.
How the implementation works
Let's investigate the elements of the ESB configuration in detail. The line numbers below are mapped with the ESB configuration shown above .
- Proxy Service [line 3 of ESB config] - The proxy service takes requests and forwards them to the back-end service, abstracting the routing logic from the client. In this example scenario, the proxy service just forwards requests to the back-end service following the Document Message EIP style.