This is a simple scenario which allows
you to create a scheduled task and in the main sequence, which has a
IN and OUT to send the request to the backend service
(SimpleStockQuote Service) and get the response and store it in the
JMS message store which points to the WSO2 Message Broker and process
it inside the ESB message processor.
- SetupFollow the first 3 steps given in the Following blog written By Sandapa Handakumbura.http://sandapa.blogspot.com/2013/02/jms-messaging-with-wso2-esb-460-and.html
a. Prerequisites
b. Step 1 - Configuring MB
c. Step 2 - Configuring ESB
d. Step 3 - Setting up the Backend
For More information : http://docs.wso2.org/wiki/display/ESB460/Configure+with+WSO2+Message+Broker
Now we have a up and running ESB and a Message Broker.
- Create a Message Store
- Login to the ESB using the Mgt Console E.g., URL : https://localhost:9444/carbon/
- Click on the Message Stores under Main → Manage → Service Bus
- Click on Add Message Stores and select Add JMS Message Store to create a JMS message store.
- Provide the mandatory parameter as below. Since we use JMS and as in above steps we have created a message store named Queue1 in jndi properties, we should configure the following as below.- Name - Queue1- Message Store Provider - org.wso2.carbon.message.store.persistence.jms.JMSMessageStore- Initial Context Factory - org.wso2.andes.jndi.PropertiesFileInitialContextFactory- Provider URL - repository/conf/jndi.properties
So the above created Message store
synapse configuration should be as follows:
<messageStore class="org.wso2.carbon.message.store.persistence.jms.JMSMessageStore" name="
Queue1
"> <parameter name="java.naming.factory.initial">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter> <parameter name="store.jms.cache.connection">false</parameter> <parameter name="java.naming.provider.url">repository/conf/jndi.properties</parameter> <parameter name="store.jms.destination">
Queue1
</parameter> <parameter name="store.jms.JMSSpecVersion">1.1</parameter> </messageStore>
- Create the Task Scheduler
- Click on the Scheduled Tasks under Main → Manage → Service Bus
- Click on Add Task to create a task.
-Task Name -TheTask
-Task Group-
synapse.simple.quartz
-Task Implementation -
org.apache.synapse.startup.tasks.MessageInjector
Properties
----------------
-format - Literal -
soap12
-to - Literal -
http://localhost:9000/services/SimpleStockQuoteService
-message - XML -
<ser:getSimpleQuote xmlns:ser="http://services.samples">
<ser:symbol>IBM</ser:symbol>
</ser:getSimpleQuote>
-soapAction - Literal -
urn:getSimpleQuote
Trigger Information of the Task
---------------------------------
--
-Trigger Type - Simple
-Count -1
-Interval (in seconds)* - 10
So the above
created Task synapse configuration should be as follows:
<task name="TheTask"
class="org.apache.synapse.startup.tasks.MessageInjector"
group="synapse.simple.quartz">
<trigger count="1" interval="25"/>
<property name="to"
value="http://localhost:9000/services/SimpleStockQuoteService"/>
<property name="soapAction" value="urn:getSimpleQuote"/>
<property name="format" value="soap12"/>
<property name="message">
<ser:getSimpleQuote xmlns:ser="http://services.samples">
<ser:symbol>IBM</ser:symbol>
</ser:getSimpleQuote>
</property>
</task>
- Create the Sequence:
Main Sequence synapse configurations should be as
follows :
<sequence name="main" trace="enable">
<in>
<log level='full' />
<send/>
</in>
<out>
<log level='full' />
<store messageStore="Queue1"/>
</out>
</sequence>
- Create a Message ProcessorClick on the Message Processors under Main → Manage → Service BusClick on Add Scheduled Message Forwarding Processor to create a processor.
Message Processor synapse configurations should be as
follows :
<messageProcessor class="org.apache.synapse.message.processors.forward.ScheduledMessageForwardingProcessor"
name="MyMsgProc"
messageStore="Queue1">
<parameter name="max.delivery.attempts">4</parameter>
<parameter name="interval">150000</parameter>
</messageProcessor>
You can view the stored messages, just by clicking on the Message Stores → Store Name (Queue1) → Show Envelope to view the particular stored message.
For more information, can refer : http://abeykoon.blogspot.com/2012/12/configuring-wso2-esb-451-with-wso2-mb.html
and
docs.wso2.org/wiki/display/ESB460/Sample+702%3A+Introduction+to+Message+Forwarding+Processor
No comments:
Post a Comment