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