Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Insert excerpt
Integration Profile Samples
Integration Profile Samples
nopaneltrue

Objective: Demonstrate the priority-based mediation capability of ESB.

Code Block
languagehtml/xml
linenumberstrue
<definitions xmlns="http://ws.apache.org/ns/synapse">
    <priority-executor name="exec">
        <queues>
            <queue size="100" priority="1"/>
            <queue size="100" priority="10"/>
        </queues>
    </priority-executor>
    <proxy name="StockQuoteProxy">
        <target>
            <inSequence>
                <filter source="$trp:priority" regex="1">
                    <then>
                        <enqueue priority="1" sequence="priority_sequence" executor="exec"/>
                    </then>
                    <else>
                        <enqueue priority="10" sequence="priority_sequence" executor="exec"/>
                    </else>
                </filter>
            </inSequence>
            <outSequence>
                <send/>
            </outSequence>
        </target>
        <publishWSDL uri="file:repositorysamples/samplesservice-bus/resources/proxy/sample_proxy_1.wsdl"/>
    </proxy>
    <sequence name="priority_sequence">
        <log level="full"/>
        <send>
            <endpoint>
                <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
            </endpoint>
        </send>
    </sequence>
</definitions>

...

In this sample, client should send a HTTP header that specifies the priority of the message. This header name is "priority". This header is retrieved in the ESB configuration using the $trp:priority XPath expression. Then it is matched against the value 1. If it has the value 1, message is executed with priority 1. Otherwise the message is executed with priority 10.

Here are two sample XML files that can be used to invoke the service using a tool like JMeter or Ab. For SOAP user interface, the user can use the WSDL repository<EI_HOME>/samples/service-bus/resources/proxy/sample_proxy_1.wsdl file to create the request. The only difference between the two requests demonstrated here is the symbol. One has the symbol as IBM and other has MSFT. For one type of request set the priority header to 1 and for the next set the priority header to 10. Then load ESB with high volume of traffic from both types of requests using the load testing tool. It prints the symbol of the incoming requests in the back end server. User should be able to see more of high priority symbol.

...