You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by ru...@apache.org on 2010/02/26 12:20:18 UTC
svn commit: r916648 - /synapse/trunk/java/src/site/xdoc/Synapse_Samples.xml
Author: ruwan
Date: Fri Feb 26 11:20:18 2010
New Revision: 916648
URL: http://svn.apache.org/viewvc?rev=916648&view=rev
Log:
Applying the patch for the issue SYNAPSE-608, documentation
Modified:
synapse/trunk/java/src/site/xdoc/Synapse_Samples.xml
Modified: synapse/trunk/java/src/site/xdoc/Synapse_Samples.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/java/src/site/xdoc/Synapse_Samples.xml?rev=916648&r1=916647&r2=916648&view=diff
==============================================================================
--- synapse/trunk/java/src/site/xdoc/Synapse_Samples.xml (original)
+++ synapse/trunk/java/src/site/xdoc/Synapse_Samples.xml Fri Feb 26 11:20:18 2010
@@ -317,6 +317,12 @@
<li>
<a href="#Sample601">Sample 601: Using Synapse Observers</a>
</li>
+ <li>
+ <a href="#Sample650">Sample 650: Priority based Mediation</a>
+ </li>
+ <li>
+ <a href="#Sample651">Sample 651: NHTTP Transport Priority based dispatching</a>
+ </li>
</ul>
</li>
</ul></div>
@@ -4277,6 +4283,7 @@
Event publish after transformation.
</p>
</div>
+
<h2>
<a name="Sample600" id="Sample600">Sample 600: File hierarchy based configuration builder</a>
</h2>
@@ -4404,4 +4411,199 @@
Refer Synapse <a href="Synapse_Extending.html#synObservers">Synapse Extending Guide</a> for more details on developing Synapse observers.
</p>
</div>
+
+ <h2>
+ <a name="Sample650" id="Sample650">Sample 650: Priority Based Message Mediation</a>
+ </h2>
+ <p>
+  
+ </p>
+ <pre xml:space="preserve"><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: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></pre>
+ <div>
+ <p>
+ <strong>Objective:</strong> Demonstrate the priority based mediation capability of synapse.
+ </p>
+ <p>
+ <strong>Prerequisites:</strong> Deploy the
+ SimpleStockQuoteService in sample Axis2 server and start it on port
+ 9000. Priority is applied only when synapse is loaded with enough messages to consume its core number of 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>
+ Start Synapse with the sample configuration 650 (i.e. synapse -sample 650).
+ </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>
+ Here are two sample XML files that can be used to invoke the service using a tool like JMeter, or Ab. 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 demonstrated requests 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 synapse with high
+ volume of traffic from both types of requests using the load testing tool. In the back end server it prints the
+ symbol of the incoming requests. User should be able to see more of high priority symbol.
+ </p>
+ <pre xml:space="preserve">
+<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>
+ </pre>
+ <pre xml:space="preserve">
+<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>
+ </pre>
+ </div>
+
+ <h2>
+ <a name="Sample651" id="Sample651">Sample 651: NHTTP Transport Priority Based Dispatching</a>
+ </h2>
+ <p>
+  
+ </p>
+ <p>
+ Here is the priority configuration file used by the NHTTP transport to determine the priority based on HTTP level properties.
+ </p>
+ <pre xml:space="preserve"><priorityConfiguration>
+ <priority-executor>
+ <!-- two priorities specified with priority 10 and 1. Both priority messages has a queue depth of 100 -->
+ <queues isFixedCapacity="true" nextQueue="org.apache.synapse.commons.executors.PRRNextQueueAlgorithm">
+ <queue size="100" priority="10"/>
+ <queue size="100" priority="1"/>
+ </queues>
+ <!-- these are the default values, values are put here to show their availability -->
+ <threads core="20" max="100" keep-alive="5"/>
+ </priority-executor>
+
+ <!-- if a message comes that we cannot determine priority, we set a default priority of 1 -->
+ <conditions defaultPriority="1">
+ <condition priority="10">
+ <!-- check for the header named priority -->
+ <equal type="header" source="priority" value="5"/>
+ </condition>
+ <condition priority="1">
+ <equal type="header" source="priority" value="1"/>
+ </condition>
+ </conditions>
+</priorityConfiguration></pre>
+ <div>
+ <p>
+ <strong>Objective:</strong> Demonstrate the priority based dispatching of NHTTP transport.
+ </p>
+ <p>
+ <strong>Prerequisites:</strong> Deploy the
+ SimpleStockQuoteService in sample Axis2 server and start it on port
+ 9000. Priority is applied only when synapse is loaded with enough messages to consume its core number of threads.
+ So to observe the priority based dispatching, it is required to use a load testing tool like JMeter, SOAP UI or Apache bench.
+ </p>
+ <p>
+ Open axis2.xml in repository/conf directory and uncomment the following parameter to the configuration.
+ <strong>priorityConfigFile</strong>. Set the value to repository/conf/sample/resources/priority/priority-configuration.xml
+ </p>
+ <p>
+ Start Synapse with the sample configuration 150 (i.e. synapse -sample 150).
+ </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 prioirty configuration. Then it is matched against
+ the value 1 and 10. Depending on this value message is executed with priority 1 or 10.
+ </p>
+ <p>
+ Here are two sample XML files that can be used to invoke the service using a tool like JMeter, or Apache Ab. 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 demonstrated requests 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 synapse with high
+ volume of traffic from both types of requests using the load testing tool. In the back end server it prints the
+ symbol of the incoming requests. User should be able to see more of high priority symbol.
+ </p>
+ <pre xml:space="preserve">
+<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>
+ </pre>
+ <pre xml:space="preserve">
+<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>
+ </pre>
+ </div>
</body></document>