| <?xml version="1.0" encoding="ISO-8859-1" ?> |
| <!-- |
| ~ Licensed to the Apache Software Foundation (ASF) under one |
| ~ or more contributor license agreements. See the NOTICE file |
| ~ distributed with this work for additional information |
| ~ regarding copyright ownership. The ASF licenses this file |
| ~ to you under the Apache License, Version 2.0 (the |
| ~ "License"); you may not use this file except in compliance |
| ~ with the License. You may obtain a copy of the License at |
| ~ |
| ~ http://www.apache.org/licenses/LICENSE-2.0 |
| ~ |
| ~ Unless required by applicable law or agreed to in writing, |
| ~ software distributed under the License is distributed on an |
| ~ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| ~ KIND, either express or implied. See the License for the |
| ~ specific language governing permissions and limitations |
| ~ under the License. |
| --> |
| |
| <document> |
| <properties> |
| <title>Apache Synapse - Sample 650</title> |
| </properties> |
| <body> |
| <section name="Sample 650: Introduction to Priority Based Mediation"> |
| <div class="xmlConf"><definitions xmlns="http://ws.apache.org/ns/synapse"> |
| |
| <priorityExecutor name="exec"> |
| <queues> |
| <queue size="100" priority="1"/> |
| <queue size="100" priority="10"/> |
| </queues> |
| </priorityExecutor> |
| |
| <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:repository/conf/sample/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></div> |
| <subsection name="Objective"> |
| <p> |
| Demonstrate the usage of priority executors in Synapse to assign priority levels |
| to requests and mediate them based on the assigned priority |
| </p> |
| </subsection> |
| <subsection name="Pre-requisites"> |
| <p> |
| <ul> |
| <li> |
| Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2 |
| </li> |
| <li> |
| Start Synapse using the configuration numbered 650 (repository/conf/sample/synapse_sample_650.xml) |
| <div class="command"> |
| Unix/Linux: sh synapse.sh -sample 650<br/> |
| Windows: synapse.bat -sample 650 |
| </div> |
| </li> |
| </ul> |
| </p> |
| </subsection> |
| <subsection name="Executing the Client"> |
| <p> |
| Priority is applied only when synapse is loaded with enough messages to consume |
| all of its core worker threads. So to observe the priority based mediation, it is |
| required to use a load testing tool like JMeter, SOAP UI or Apache bench. |
| </p> |
| <p> |
| 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 synapse |
| 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. |
| </p> |
| <p> |
| Messages with different priorities are put into different priority queues. Then they |
| are mediated in a manner so that high priority messages are always processed first. |
| </p> |
| <p> |
| Here are two sample SOAP requests that can be used to invoke the service using a |
| tool like JMeter, or Apache Bench. For SOAP UI, user can use the WSDL |
| repository/conf/sample/resources/proxy/sample_proxy_1.wsdl to create the request. |
| The only difference between the two requests shown here is the symbol. One |
| has the symbol as IBM and other has MSFT. For one type of requests set the priority |
| header to 1 and for the next set the priority header to 10. Then load Synapse with |
| a large volume of traffic consisting of both types of requests using the load testing tool. |
| Back end Axis2 server prints the symbol of the incoming requests. User should be |
| able to see more of the high priority symbol. |
| </p> |
| <div class="xmlConf"><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> |
| <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"> |
| <wsa:To>http://localhost:8281/services/SimpleStockQuoteService</wsa:To> |
| <wsa:MessageID>urn:uuid:1B57D0B0BF770678DE1261165228620</wsa:MessageID> |
| <wsa:Action>urn:getQuote</wsa:Action> |
| </soapenv:Header> |
| <soapenv:Body> |
| <m0:getQuote xmlns:m0="http://services.samples"> |
| <m0:request> |
| <m0:symbol>IBM</m0:symbol> |
| </m0:request> |
| </m0:getQuote> |
| </soapenv:Body> |
| </soapenv:Envelope></div> |
| <div class="xmlConf"><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> |
| <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"> |
| <wsa:To>http://localhost:8281/services/SimpleStockQuoteService</wsa:To> |
| <wsa:MessageID>urn:uuid:1B57D0B0BF770678DE1261165228620</wsa:MessageID> |
| <wsa:Action>urn:getQuote</wsa:Action> |
| </soapenv:Header> |
| <soapenv:Body> |
| <m0:getQuote xmlns:m0="http://services.samples"> |
| <m0:request> |
| <m0:symbol>MSFT</m0:symbol> |
| </m0:request> |
| </m0:getQuote> |
| </soapenv:Body> |
| </soapenv:Envelope></div> |
| </subsection> |
| </section> |
| <p><a href="../samples.html">Back to Catalog</a></p> |
| </body> |
| </document> |