0

I inserted some json content in a queue of WSO2 Message Broker using an API of WSO2 ESB:

<?xml version="1.0" encoding="UTF-8"?>
<inSequence xmlns="http://ws.apache.org/ns/synapse">
    <property name="Accept" scope="transport" type="STRING" value="application/json"/>
    <call>
        <endpoint>
            <http method="GET" uri-template="http://localhost:9769/services/orderApi/orders"/>
        </endpoint>
    </call>
    <iterate continueParent="true" expression="//orders/order">
        <target sequence="insertOrdersMQ"/>
    </iterate>
    <respond/>
</inSequence>

In this API, I iterated at the json response of the endpoint and inserted the orders in one Message Broker's queue using this sequence:

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="insertOrdersMQ" xmlns="http://ws.apache.org/ns/synapse">
    <log level="custom">
        <property name="Log: " value="Inserting order on queue"/>
    </log>
    <property name="OUT_ONLY" value="true"/>
    <property name="FORCE_SC_ACCEPTED" scope="axis2" value="true"/>
    <send>
        <endpoint>
            <address uri="jms:/orders_mb?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp;java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory&amp;java.naming.provider.url=repository/conf/jndi.properties&amp;transport.jms.DestinationType=queue"/>
        </endpoint>
    </send>
</sequence> 

Then, I created a Message Processor at WSO2 ESB, because I want to consume these messages on orders_mb queue and use then in another sequence. Here is the code of the Message Store and Message Processor:

<messageStore name="orders_Store" class="org.apache.synapse.message.store.impl.jms.JmsStore" xmlns="http://ws.apache.org/ns/synapse">
   <parameter name="java.naming.factory.initial">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
   <parameter name="java.naming.provider.url">repository/conf/jndi.properties</parameter>
   <parameter name="store.jms.destination">orders_mb</parameter>
   <parameter name="store.jms.JMSSpecVersion">1.1</parameter>
   <parameter name="store.producer.guaranteed.delivery.enable">false</parameter>
   <parameter name="store.failover.message.store.name">orders_mb</parameter>
</messageStore>


<messageProcessor name="ordersProcessor" class="org.apache.synapse.message.processor.impl.sampler.SamplingProcessor" messageStore="orders_Store" xmlns="http://ws.apache.org/ns/synapse">
   <parameter name="interval">1000</parameter>
   <parameter name="concurrency">1</parameter>
   <parameter name="sequence">insertOrdersDB</parameter>
   <parameter name="is.active">true</parameter>
</messageProcessor>

Finally, here is the sequence that the Message Processor send the message of the queue:

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="insertOrdersDB" xmlns="http://ws.apache.org/ns/synapse">
    <log level="full">
        <property name="Log: " value="Removing order from queue"/>
    </log>
</sequence>

When I call the API resource to insert the orders in queue, it works. However, when the Message Processor consume then, it logs out

[2017-07-13 10:06:34,856] WARN - JmsConsumer [orders_mb-C-1]. Did not receive a javax.jms.ObjectMessage

I don't know what went wrong, and I saw this question that asks about the same problem, however, I already inserted the properties that are mandatory and it not worked here yet.

Community
  • 1
  • 1
mhery
  • 2,097
  • 4
  • 26
  • 35

1 Answers1

0

Try using the call mediator in blocking mode.

Nadeeshaan
  • 356
  • 5
  • 15