wso2wso2-message-brokerwso2-esb

Can I log in a file the web service response called by a WSO2 message processor?


I am pretty new in WSO2 ESB and I have the following problem.

Into my ESB flow I have a Store mediator that put an XML document ino a WSO2 MB queue, this is the configuration of my message store:

<?xml version="1.0" encoding="UTF-8"?>
<messageStore class="org.apache.synapse.message.store.impl.jms.JmsStore" name="glisMessageStore" xmlns="http://ws.apache.org/ns/synapse">
    <parameter name="store.jms.destination">glisQueue</parameter>
    <parameter name="store.producer.guaranteed.delivery.enable">false</parameter>
    <parameter name="store.jms.cache.connection">true</parameter>
    <parameter name="java.naming.factory.initial">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
    <parameter name="connectionfactory.QueueConnectionFactory">amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5675'</parameter>
    <parameter name="store.jms.JMSSpecVersion">1.1</parameter>
</messageStore>

As you can see my documents are putted into the glisQueue queue.

Then I deployed (with this project) a Message Processor named glisMessageProcessor that check if the queue is not empty and if it contains some XML documents it send to and external web service performing an Http call, this is the configuration of my message processor:

<?xml version="1.0" encoding="UTF-8"?>
<messageProcessor class="org.apache.synapse.message.processor.impl.forwarder.ScheduledMessageForwardingProcessor" messageStore="glisMessageStore" name="glisMessageProcessor" targetEndpoint="glisEndpoint" xmlns="http://ws.apache.org/ns/synapse">
    <parameter name="client.retry.interval">1000</parameter>
    <parameter name="max.delivery.attempts">4</parameter>
    <parameter name="member.count">1</parameter>
    <parameter name="message.processor.reply.sequence">glisResponseSequence</parameter>
    <parameter name="max.delivery.drop">Disabled</parameter>
    <parameter name="interval">1000</parameter>
    <parameter name="is.active">true</parameter>
</messageProcessor>

As you can see it is using the glisMessageStore as data source (so it is using the glisQueue queue defiend in it to obtain the data to send) and send these data to the glisEndpoint that is the endpoint of my web service (it is defined in my project).

It works fine, the data are correctly sended to the external web service represented by the glisEndpoint.

My only problem is: my web service returns a message when is called (containing some information that I need to store in some way).

Can I configure in some way my glissMessageProcessor to retrieve these response message and put it in a log file?


Solution

  • You just have to use log mediator inside the sequence named "glisResponseSequence" : this is what you've defined with "message.processor.reply.sequence" parameter ant this is where goes the response.