The Point-to-Point Channel EIP pattern allows only a single receiver to consume a sent message when there are multiple receivers waiting to consume it.
For more information, go to Point to Point Channel.
The following sections explain how you can implement a sample scenario of this EIP using the ESB profile of WSO2 EI.
The sample scenario is an inventory for stocks. It illustrates how a stock quote is generated, which only a single consumer receives at a given time. The diagram below depicts how to simulate the sample scenario using the ESB profile.
When you unzip the ZIP file you download below in Step 6 when simulating the sample scenario, you can find the below configurations in the
<UNZIPPED_FILE>/src/main/synapse-config directory. For more information about these artifacts, go to WSO2 EI Documentation.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="PointToPointProxy" transports="http https" startOnLoad="true" > <target> <inSequence> <send> <endpoint> <!-- Channel With Multiple Endpoints Load Balancer Will Ensure that only one will receive it --> <loadbalance> <endpoint> <address uri="http://localhost:9000/services/SimpleStockQuoteService/" /> </endpoint> <endpoint> <address uri="http://localhost:9001/services/SimpleStockQuoteService/" /> </endpoint> <endpoint> <address uri="http://localhost:9002/services/SimpleStockQuoteService/" /> </endpoint> </loadbalance> </endpoint> </send> </inSequence> <outSequence> <respond/> </outSequence> </target> </proxy>
Simulating the sample scenario
Follow the below instructions to simulate this sample scenario.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.samples" xmlns:xsd="http://services.samples/xsd"> <soapenv:Header /> <soapenv:Body> <ser:getQuote> <ser:request> <ser:symbol>foo</ser:symbol> </ser:request> </ser:getQuote> </soapenv:Body> </soapenv:Envelope>
Analyzing the output
Out of the three instances of the
Stock Quote service (Axis2 server), only one server acquires the sent request at a given time. When you execute the request, the ESB profile first receives the message and then routes it to the back-end service (StockQuoteService). The following output will be printed on the Axis2 Server Console:
The generated stock quote will then be sent to the client application (Stock Quote Client). The following output will be printed on the client application Console:
If you try sending multiple requests, the Console logs of each of the Axis2 server instances will display that the three of them are receiving the message one after the other (i.e., in Round Robin pattern).