You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by ch...@apache.org on 2011/05/25 04:54:31 UTC
svn commit: r1127367 - /synapse/trunk/java/src/site/xdoc/Synapse_Samples.xml
Author: charith
Date: Wed May 25 02:54:30 2011
New Revision: 1127367
URL: http://svn.apache.org/viewvc?rev=1127367&view=rev
Log:
updating synapse sample doc
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=1127367&r1=1127366&r2=1127367&view=diff
==============================================================================
--- synapse/trunk/java/src/site/xdoc/Synapse_Samples.xml (original)
+++ synapse/trunk/java/src/site/xdoc/Synapse_Samples.xml Wed May 25 02:54:30 2011
@@ -356,12 +356,18 @@
</li>
</ul>
</li>
- <li>
- <a href="#MessageStore">Synapse Message Stores (Dead Letter Channel)</a>
+ <li>
+ <a href="#StoreNFwd">Store and Forward Messaging patterns with Message Stores and Message Processors</a>
<ul>
<li>
<a href="#Sample700">Sample 700: Introduction to Synapse Message Store </a>
</li>
+ <li>
+ <a href="#Sample701">Sample 701: Introduction to Synapse Message Sampling Processor</a>
+ </li>
+ <li>
+ <a href="#Sample702">Sample 702: Introduction to Synapse Message Forwarding Processor </a>
+ </li>
</ul>
</li>
</ul></div>
@@ -5612,64 +5618,188 @@ following on the console:</p>
<p>Invoke the client as follows.</p>
<pre xml:space="preserve">ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=SUN/
</pre>
- <h2>
- <a name="Message Store" id="MessageStore">Introducing Synapse Message store</a></h2>
- <h2>
- <a name="Sample700" id="Sample700">Sample 700: Introduction to Synapse Message Store</a></h2>
- <pre xml:space="preserve"><!-- Introduction to the Synapse Message Store -->
- <definitions xmlns="http://ws.apache.org/ns/synapse">
- <!--Simple in Memory Message Store with name foo -->
- <messageStore name="foo" sequence="bar">
- <redelivery>
- <!--retry interval 1 sec -->
- <interval>1</interval>
- <!--Message will be stored after 2 redeliveries -->
- <maximumRedeliveries>2</maximumRedeliveries>
- <exponentialBackoff>true</exponentialBackoff>
- <backoffMutiplier>2</backoffMutiplier>
- </redelivery>
- </messageStore>
-
- <!-- filtering of messages with XPath and regex matches -->
- <sequence name="main">
- <filter source="get-property('To')" regex=".*/StockQuote.*">
- <send>
- <endpoint key="SampleEndpoint"/>
- </send>
- <drop/>
- </filter>
- <send/>
- </sequence>
- <!-- Endpoint named SampleEndpoint-->
- <endpoint name="SampleEndpoint" onFault="foo">
- <address uri="http://localhost:9000/services/SimpleStockQuoteService">
- <suspendDurationOnFailure>2</suspendDurationOnFailure>
- </address>
- </endpoint>
-
- <sequence name="bar">
+ <h2>
+ <a name="StoreNFwd" id="StoreNFwd">Store and Forward Messaging patterns with Message
+ Stores and Message Processors
+ </a>
+ </h2>
+ <p>
+ Synapse Message Stores and Message Processors can be used to implement different store
+ and forward messaging patterns.
+ This can be use to cater different SLA s and other QoS aspects.
+ </p>
+ <h2>
+ <a name="Sample700" id="Sample700">Sample 700: Introduction to Synapse Message Store</a></h2>
+ <pre xml:space="preserve">
+ <!-- Introduction to the Synapse Message Store -->
+ <definitions xmlns="http://ws.apache.org/ns/synapse">
+ <sequence name="fault">
+ <log level="full">
+ <property name="MESSAGE" value="Executing default 'fault' sequence"/>
+ <property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
+ <property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
+ </log>
+ <drop/>
+ </sequence>
+ <sequence name="onStoreSequence">
+ <log>
+ <property name="On-Store" value="Storing message"/>
+ </log>
+ </sequence>
+ <sequence name="main">
+ <in>
<log level="full"/>
- </sequence>
- </definitions>
- </pre>
+ <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
+ <store messageStore="MyStore" sequence="onStoreSequence"/>
+ </in>
+ <description>The main sequence for the message mediation</description>
+ </sequence>
+ <messageStore name="MyStore"/>
+ </definitions>
+ </pre>
<p>
<strong>Objective: </strong>Introduction to Synapse Message Stores</p>
- <p>
<strong>Prerequisites</strong>:
<br/>Start the Synapse configuration numbered 700: i.e. synapse -sample 700
- <br/>Start the Axis2 server and deploy the SimpleStockQuoteService if not already done</p>
<p>To Execute the Client : </p>
- <pre xml:space="preserve">ant stockquote -Dtrpurl=http://localhost:8280/soap/StockQuote</pre>
- <p>Since now you have the Axis2 Server Running when you run the client you will get the Stock
- generation output in Server console and the out put in the client side. Then try shutting down
- the Axis2 Server and running again. You will see synapse will try 2 times to deliver the message
- and store in on the MessageStore.It will execute the log sequence before storing the Message
- in the Message store.</p>
+ <pre xml:space="preserve">ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dmode=placeorder
+ </pre>
+ <p>When you execute the client the message will be dispatched to the main sequence.
+ In the Main sequence store mediator will store the placeOrder request message in the "MyStore" Message Store</p>
+
+ <p>Before Storing the message store mediator will invoke the sequence :onStoreSequence. See the log</p>
+ <p>INFO - LogMediator To: http://localhost:9000/services/SimpleStockQuoteService, WSAction: urn:placeOrder, SOAPAction: urn:placeOrder, ReplyTo: http://www.w3.org/2005/08/addressing/none, MessageID: urn:uuid:54f0e7c6-7b43-437c-837e-a825d819688c, Direction: request, On-Store = Storing message
+ </p>
+
<p>You can then use the JMX view of Synapse Message Store by using the jconsole and view the stored
- Message.You can even re start the Axis2Server and manually redeliver the request using the
- Same JMX view.
+ Messages and delete them.
</p>
+ <h2>
+ <a name="Sample701" id="Sample701">Sample 701: Introduction to Synapse Message Sampling Processor</a></h2>
+ <pre xml:space="preserve">
+ <!-- Introduction to Synapse Message Sampling Processor -->
+
+ <definitions xmlns="http://ws.apache.org/ns/synapse">
+
+ <sequence name="send_seq">
+ <send>
+ <endpoint>
+ <address uri="http://localhost:9000/services/SimpleStockQuoteService">
+ <suspendOnFailure>
+ <errorCodes>-1</errorCodes>
+ <progressionFactor>1.0</progressionFactor>
+ </suspendOnFailure>
+ </address>
+ </endpoint>
+ </send>
+ </sequence>
+ <sequence name="main">
+ <in>
+ <log level="full"/>
+ <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
+ <property name="OUT_ONLY" value="true"/>
+ <store messageStore="MyStore"/>
+ </in>
+ <description>The main sequence for the message mediation</description>
+ </sequence>
+ <messageStore name="MyStore"/>
+ <messageProcessor
+ class="org.apache.synapse.message.processors.sampler.SamplingProcessor"
+ name="SamplingProcessor" messageStore="MyStore">
+ <parameter name="interval">20000</parameter>
+ <parameter name="sequence">send_seq</parameter>
+ </messageProcessor>
+ </definitions>
+ </pre>
+ <p>
+ <strong>Objective:</strong>Introduction to Synapse Message Sampling Processor
+ </p>
+ <strong>Prerequisites</strong>:
+ <br/>Start the Synapse configuration numbered 701: i.e. synapse -sample 701
+ <p>Start the SimpleStockQuoteService if its not already started</p>
+ <p>To Execute the Client few times:</p>
+ <pre xml:space="preserve">ant stockquote
+ -Daddurl=http://localhost:9000/services/SimpleStockQuoteService
+ -Dtrpurl=http://localhost:8280/ -Dmode=placeorder
+ </pre>
+ <p>When you execute the client the message will be dispatched to the main sequence.
+ In the Main sequence store mediator will store the placeOrder request message in the
+ "MyStore" Message Store
+ </p>
+
+ <p>Message Processor will consume the messages and forward to the send_seq sequence in
+ configured rate.
+ </p>
+ <p>You will observe that service invocation rate is not changing when increasing the rate we
+ execute the client.
+ </p>
+ <h2>
+ <a name="Sample702" id="Sample702">Sample 702: Introduction to Synapse Message Forwarding Processor</a></h2>
+ <pre xml:space="preserve">
+
+ <!-- Introduction to Synapse Scheduled Message Forwarding Processor -->
+
+ <definitions xmlns="http://ws.apache.org/ns/synapse">
+
+ <endpoint name="StockQuoteServiceEp">
+ <address uri="http://localhost:9000/services/SimpleStockQuoteService">
+ <suspendOnFailure>
+ <errorCodes>-1</errorCodes>
+ <progressionFactor>1.0</progressionFactor>
+ </suspendOnFailure>
+ </address>
+ </endpoint>
+ <sequence name="fault">
+ <log level="full">
+ <property name="MESSAGE" value="Executing default 'fault' sequence"/>
+ <property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
+ <property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
+ </log>
+ <drop/>
+ </sequence>
+ <sequence name="main">
+ <in>
+ <log level="full"/>
+ <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
+ <property name="OUT_ONLY" value="true"/>
+ <property name="target.endpoint" value="StockQuoteServiceEp"/>
+ <store messageStore="MyStore"/>
+ </in>
+ <description>The main sequence for the message mediation</description>
+ </sequence>
+ <messageStore name="MyStore"/>
+ <messageProcessor
+ class="org.apache.synapse.message.processors.forward.ScheduledMessageForwardingProcessor"
+ name="ScheduledProcessor" messageStore="MyStore">
+ <parameter name="interval">10000</parameter>
+ </messageProcessor>
+ </definitions>
+ </pre>
+ <p>
+ <strong>Objective: </strong>Introduction to Synapse Message Forwarding Processor</p>
+ <strong>Prerequisites</strong>:
+ <br/>Start the Synapse configuration numbered 702: i.e. synapse -sample 702
+
+ <p>To Execute the Client: </p>
+ <pre xml:space="preserve">ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dmode=placeorder
+</pre>
+
+ <p>Now Start the SimpleStockQuoteService</p>
+ <p>When you Start the service you will see message getting delivered to the service. Even
+ though service is down when we invoke it from the client
+ </p>
+ <p>Here in the Main sequence store mediator will store the placeOrder request message in the
+ "MyStore" Message Store
+ </p>
+ <p>Message Processor will send the message to the endpoint configured as a message context
+ property.
+ </p>
+ <p>Message processor will remove the message from the store only if message delivered
+ successfully
+ </p>
+
</div>
-</body></document>
+</body>
+</document>