Saturday, February 16, 2013

JMS MessageStore with proper error handling



Following
 demonstrates the configuration in ESB, when message comes, first the given message getting persist at the JMSStore, and the client acknowledged with proper response, if fails to store in JMS store it will sends the SOAP fault to the client thus the client can implement mechanism to retry the message for a period till it get success



<proxy xmlns="http://ws.apache.org/ns/synapse" name="StockQuoteProxy" transports="http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
        <property name="OUT_ONLY" value="true"/>
        <property name="target.endpoint" value="JMSEP"/>
         <property name="enableREST" value="true"/>
         <store messageStore="JMSMS"/>
         <payloadFactory>
            <format>
               <esbResponse xmlns="">
                  <text> added sccuessfully </text>
               </esbResponse>
            </format>
         </payloadFactory>
         <header name="To" action="remove"/>
         <property name="RESPONSE" value="true" scope="default" type="STRING"/>
         <send/>
      </inSequence>
      <faultSequence>
         <makefault version="soap11">
            <code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:VersionMismatch"/>
            <reason value="test"/>
            <role>MessageStoreFault</role>
            <detail>MessageStoreFault</detail>
         </makefault>
         <send/>
      </faultSequence>
   </target>
   <publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/>
   <description></description>
</proxy>


<endpoint xmlns="http://ws.apache.org/ns/synapse" name="JMSEP">
   <address uri="jms:/SimpleStockQuoteService?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616" format="pox">
      <suspendOnFailure>
         <progressionFactor>1.0</progressionFactor>
      </suspendOnFailure>
      <markForSuspension>
         <retriesBeforeSuspension>0</retriesBeforeSuspension>
         <retryDelay>0</retryDelay>
      </markForSuspension>
      <timeout>
         <duration>1000</duration>
         <responseAction>fault</responseAction>
      </timeout>
   </address>
</endpoint>

<messageStore name="JMSMS" class="org.wso2.carbon.message.store.persistence.jms.JMSMessageStore" xmlns="http://ws.apache.org/ns/synapse">
   <parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
   <parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
   <parameter name="store.jms.destination">JMSMS</parameter>
   <parameter name="store.jms.JMSSpecVersion">1.1</parameter>
   <parameter name="store.jms.cache.connection">false</parameter>
</messageStore>

<messageProcessor name="Processor1" class="org.apache.synapse.message.processors.forward.ScheduledMessageForwardingProcessor" messageStore="JMSMS" xmlns="http://ws.apache.org/ns/synapse">
   <parameter name="interval">4000</parameter>
</messageProcessor>

No comments:

Post a Comment