Monday, January 2, 2012

Defining JMS proxy to listen to a particular queue in wso2esb

There are  use cases, where user needs to define number of jms queues for different purposes and proxies will listen to those queues and do further processing with messages.
There is a predefined service level parameter available in axis2   to make 'jms' proxies to listen particular queues.
Check the following simple sample(for qpid), where 'ErrorProxy" listens a  queue named as "errorqueue".

<proxy xmlns="http://ws.apache.org/ns/synapse" name="ErrorProxy" transports="https,http,jms" statistics="disable" trace="disable" startOnLoad="true">
   <target inSequence="ErrorInSequence" endpoint="ErrorQueueEndpoint" />
   <parameter name="transport.jms.ContentType">
      <rules>
         <jmsProperty>contentType</jmsProperty>
         <default>text/xml</default>
      </rules>
   </parameter>
   <parameter name="transport.jms.ConnectionFactory">myQueueConnectionFactory</parameter>
   <parameter name="transport.jms.DestinationType">queue</parameter>
   <parameter name="transport.jms.Destination">errorqueue</parameter>
</proxy> 
You have to enable jms transport in your axis2.xml.

eg:
<transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">
  <parameter name="myQueueConnectionFactory" locked="false">
   <parameter name="java.naming.factory.initial" locked="false"> org.apache.qpid.jndi.PropertiesFileInitialContextFactory</parameter>
   <parameter name="java.naming.provider.url" locked="false">repository/conf /jndi.properties</parameter>
   <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false"> QueueConnectionFactory</parameter>
   <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue< /parameter>
  </parameter>

Need to add following entry at jndi.properties file
  queue.errorqueue = example.errorqueue


ErrorInSequence Configuration
--------------------------------------
<sequence xmlns="http://ws.apache.org/ns/synapse" name="ErrorInSequence">
   <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2" />
   <property name="OUT_ONLY" value="true" scope="default"/>
     <log level="custom">
      <property name="Picked message" value="************" />
   </log>
   <description></description>
</sequence> 

This sequence receives the error message,which is stored at error queue

No comments:

Post a Comment