user3592182
user3592182

Reputation: 25

How to Read Data from a file and store it in message store in WSO2

Can anyone please suggest how I can read data from one file and add it to a message store .

I am trying to develop a message resend functionality in ESB .

Idea :

Message goes from one proxy service to destination point

Save messages in different files (One message per file) .

Write a another proxy service that will read content from all files from a folder and put them in a message store .

Now a processor will be on the top of store that will send messages from store to destination point .

Regards Mahesh

Upvotes: 0

Views: 786

Answers (2)

Vanji
Vanji

Reputation: 1704

This issue is due to not enabling the vfs transport sender in the axis2.xml configuration.

Upvotes: 0

Jean-Michel
Jean-Michel

Reputation: 5946

Message store "MyStore" in ActiveMQ :

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

Message Processor : read from the store and send message to an endpoint "MyEPR"

<messageProcessor xmlns="http://ws.apache.org/ns/synapse" class="org.apache.synapse.message.processor.impl.forwarder.ScheduledMessageForwardingProcessor" name="MyStoreForwarder" targetEndpoint="MyEPR" messageStore="MyStore">
    <parameter name="message.processor.reply.sequence">MyReplySequence</parameter>
    <parameter name="max.delivery.attempts">-1</parameter>
    <parameter name="client.retry.interval">5000</parameter>
    <parameter name="interval">10</parameter>
    <parameter name="message.processor.fault.sequence">MyFaultSequence</parameter>
    <parameter name="is.active">true</parameter>
</messageProcessor>

Proxy service : read xml files in file:///home/test and store them into "MyStore"

<proxy xmlns="http://ws.apache.org/ns/synapse" name="MyProxy" transports="vfs" statistics="disable" trace="disable" startOnLoad="true">
   <target>
    <inSequence>
      <store messageStore="MyStore"/>
    </inSequence>
   </target>
   <parameter name="transport.PollInterval">15</parameter>
   <parameter name="transport.vfs.FileURI">file:///home/test</parameter>
   <parameter name="transport.vfs.FileNamePattern">.*.xml</parameter>
   <parameter name="transport.vfs.ContentType">application/xml; charset=ISO-8859-1</parameter>
</proxy>

Upvotes: 1

Related Questions