Search code examples
wso2wso2-enterprise-integratorwso2-micro-integrator

Is there a way to call a WSO2 proxy service from a sequence?


I am trying to collect data every minute from a REST API and send data to an MQTT Broker.

To realized this I've create a task and some sequences.

I have a sequence that retrieve the API Token from the Restfull API with credentials then call another sequence that call the Restfull API with the token to make a request to the API. The API then return my the result of the request.

I've manage to create a Proxy Service that send dummy data to an MQTT Broker, but I'm not able to call this Proxy Service after the Rest API return me the data.

How can I call the proxy service after the Token and the data is return to me?

I'm really new to WSO2 so if you know a better way to organize this process please feel free to share your knowledge.

I'm using WSO2 Entreprise Integrator 7.1.0, WSO2 Micro Integrator 1.2.0.

Thanks


Solution

  • The simplest way is to create sequence for send data to MQTT, like below, and call it.

    <sequence xmlns="http://ws.apache.org/ns/synapse" name="send.mqtt">
       <property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
       <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2" type="STRING"/>
       <property name="target.endpoint" value="StockReqEndPoint"/>
       <send>
          <endpoint>
            <address uri="mqtt:/SampleProxy?mqtt.server.host.name=localhost&amp;mqtt.server.port=1883&amp;mqtt.client.id=esb.test.sender&amp;mqtt.topic.name=esb.test2&amp;mqtt.subscription.qos=2&amp;mqtt.blocking.sender=true"/>
          </endpoint>
       </send>
    </sequence>