...
Introduction to Message Router
The Message Router EIP reads the content of a message and routes it to a specific recipient based on its content. When the implementation of a specific logical function is distributed across multiple physical systems, an incoming request needs to be passed on to the correct service, based on the request's content. A Message Router is useful in handling such scenarios.
...
You need to set up the ESB, and the back-end serviceservices:
Download the
Message-Router.zip
file, which includes the ESB configuration described above.Note Note that you need to start two instances of the Axis2 server to run in ports 9000 and 9001 by executing the following commands:
./axis2server.
sh -http9000
-https
9002
-name MyServer1
./axis2server.sh -http
9001
-https
9003
-name MyServer2
See Setting up the Environment for instructions on setting up the ESB and the back-end service.
Info When you set up the environment, note that you need to start two instances of the back-end service (Stock Quote Service) to simulate this example.
Executing the sample
Let's send a request to the ESB using the Stock Quote Client application. Find out more about the Stock Quote Client from the ESB documentation.
...
When you send the request, the ESB first receives the message and then routes it to the relevant back-end service (foo inventory service
). The following output will be printed on the Axis2 server's console, confirming that the request is successfully received by the back-end service.
Code Block |
---|
samples.services.SimpleStockQuoteService :: Generating quote for : foo |
The stock quote generated by the 'foo' service will then be sent to the client application (Stock Quote Client). The following output will be printed on the client application's console:
Code Block |
---|
Standard :: Stock price = $77.86763451813164 |
Now, change the -Dsymbol
parameter to bar
, and send another request as shown below.
...
See that the request goes to the bar inventory service
. The The following output will be printed on the Axis2 server's console :
...
(bar inventory service
), confirming that the request is successfully received by the relevant back-end service.
Code Block |
---|
samples.services.SimpleStockQuoteService :: Generating quote for : bar |
The stock quote generated by the 'bar' service will then be sent to the client application (Stock Quote Client). The following output will be printed on the client application's console:
Code Block |
---|
Standard :: Stock price = $64.81823486260222 |