Tuesday, June 21, 2011

Local Transport implementation for WSO2 ESB

Apache Axis2's non blocking local transport implementation is used to make internal service calls and transfer data within proxy services. The class org.apache.axis2.transport.local.NonBlockingLocalTransportSender implements the sender API. The transport does not have a receiver implementation and does not accept any configuration parameters as of now. This transport will work seamlessly against the ESB's Nhttp transport. This new transport is available with the latest [1] release of WSO2 ESB (ie. wso2esb-4.0.0). The binary distro can be downloaded from [2].

Scenario :

Inorder to demonstrate the use of local transport, let's consider following scenario. The ESB contains three proxy services. The stockquote client invokes the LocalTransportProxy. Then the message will be sent to the SecondProxy and then it will be sent to the StockQuoteProxy. The StockQuoteProxy will invoke the backend service and return the response to the client.

1) Without local transport
If you have a look at the above diagram you might notice that each call between proxy services are going through the network.

Synapse Configuration:

<definitions xmlns="http://ws.apache.org/ns/synapse">
<proxy xmlns="http://ws.apache.org/ns/synapse" name="LocalTransportProxy"
transports="https http" startOnLoad="true" trace="disable">
<target>
<endpoint name="ep1">
<address uri="http://localhost:9000/services/SecondProxy"/>
</endpoint>
<inSequence>
<log level="full"/>
<log level="custom">
<property name="LocalTransportProxy" value="In sequence of LocalTransportProxy invoked!"/>
</log>
</inSequence>
<outSequence>
<log level="custom">
<property name="LocalTransportProxy" value="Out sequence of LocalTransportProxy invoked!"/>
</log>
<send/>
</outSequence>
</target>
<publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/>
</proxy>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="SecondProxy"
transports="https http" startOnLoad="true" trace="disable">
<target>
<endpoint name="ep2">
<address uri="http://localhost:9000/services/StockQuoteProxy"/>
</endpoint>
<inSequence>
<log level="full"/>
<log level="custom">
<property name="SecondProxy" value="In sequence of Second proxy invoked!"/>
</log>
</inSequence>
<outSequence>
<log level="custom">
<property name="SecondProxy" value="Out sequence of Second proxy invoked!"/>
</log>
<send/>
</outSequence>
</target>
<publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/>
</proxy>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="StockQuoteProxy"
startOnLoad="true">
<target>
<endpoint name="ep3">
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
<outSequence>
<log level="custom">
<property name="StockQuoteProxy"
value="Out sequence of StockQuote proxy invoked!"/>
</log>
<send/>
</outSequence>
</target>
<publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/>
</proxy>
</definitions>
2) With local transport
In this sample, the communication between proxy services are done through the Local transport. Since Local transport calls are in-JVM calls, it will reduce the time taken for the communication between proxy services (will not introduce any network overhead).

Synapse Configuration:
<definitions xmlns="http://ws.apache.org/ns/synapse">
<proxy xmlns="http://ws.apache.org/ns/synapse" name="LocalTransportProxy"
transports="https http" startOnLoad="true" trace="disable">
<target>
<endpoint name="ep1">
<address uri="local://localhost/services/SecondProxy"/>
</endpoint>
<inSequence>
<log level="full"/>
<log level="custom">
<property name="LocalTransportProxy" value="In sequence of LocalTransportProxy invoked!"/>
</log>
</inSequence>
<outSequence>
<log level="custom">
<property name="LocalTransportProxy" value="Out sequence of LocalTransportProxy invoked!"/>
</log>
<send/>
</outSequence>
</target>
<publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/>
</proxy>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="SecondProxy"
transports="https http" startOnLoad="true" trace="disable">
<target>
<endpoint name="ep2">
<address uri="local://localhost/services/StockQuoteProxy"/>
</endpoint>
<inSequence>
<log level="full"/>
<log level="custom">
<property name="SecondProxy" value="In sequence of Second proxy invoked!"/>
</log>
</inSequence>
<outSequence>
<log level="custom">
<property name="SecondProxy" value="Out sequence of Second proxy invoked!"/>
</log>
<send/>
</outSequence>
</target>
<publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/>
</proxy>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="StockQuoteProxy"
startOnLoad="true">
<target>
<endpoint name="ep3">
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
<outSequence>
<log level="custom">
<property name="StockQuoteProxy"
value="Out sequence of StockQuote proxy invoked!"/>
</log>
<send/>
</outSequence>
</target>
<publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/>
</proxy>
</definitions>
If you are interested in running this local transport sample, refer [3]. I am planning to do a performance benchmark against this local transport. Stay tuned for my followup post on local transport performance.

References

5 comments:

Justin Blandford said...

Hi,
I'm interested in understanding a little more about how local transport may aid performance within the WSO2 ESB. Your blog shows that the Proxy Services can communicate via local transport with the local prefix. However, if a Web Application is also installed on the same ESB (by adding the Web Application Deployer features to the ESB), is it possible to use local transport to communicate with the Web Service Endpoint (so the Stock Quote WS would be local to the ESB)? I'm trying to figure out if there is any way that we can achieve an 'InVM' type communication as opposed to making a communication via http? I've tried prefixing the actual Web Service call with local but it falls over. Also, on the sample at http://wso2.org/project/esb/java/4.0.3/docs/quickstart_guide.html, there is 'local' transport on the screenshot. I don’t see this listed when I create a proxy and don’t see it on the configure transport options? Any suggestions on how to enable this?

Justin Blandford said...

I'm interested in understanding a little more about how local transport may aid performance within the WSO2 ESB. I have looked at your blog which suggests that the Proxy Services can communicate via local transport with the local prefix. However, if a Web Application is also installed on the same ESB (by adding the Web Application Deployer features to the ESB), is it possible to use local transport to communicate with the Web Service Endpoint (so for example the StockQuoteWS war file is deployed on the ESB)? I'm trying to figure out if there is any way that we can achieve an 'InVM' type communication as opposed to making a communication via http? I've tried prefixing the actual Web Service call with local but it falls over. Also, on the sample at http://wso2.org/project/esb/java/4.0.3/docs/quickstart_guide.html, there is 'local' transport on the screenshot. I don’t see this listed when I create a proxy and don’t see it on the configure transport options?

Heshan Suriyaarachchi said...

Hi Justin,

Yes you should be able to do this. I wrote this post sometime back and I have not been in touch with the development activity of WSO2 ESB. It might be the case that WSO2 ESB no longer ships the non-blocking local transport with the ESB. That may be the reason why it's not being listed as you have observed. Can you ask your questions in the WSO2 Carbon Developer mailing list.

Lucas Pires said...

Hy,

I've trying to use local transport with JMS ActiveMQ, I posted my problem at stackoverflow:

http://stackoverflow.com/questions/34200656/wso2-esb-not-serialize-jms-activemq-with-local-transport


Do you have experiences with a similar architecture?

Heshan Suriyaarachchi said...

Hi Lucas,

I no longer work for WSO2 and have not kept up with their codebase. Please reach out the WSO2 Carbon developers mailing list and ask your question.

Thanks,
Heshan.