WSO2 ESB中用于REST请求的计划任务



我想在WSO2 ESB中调度任务,以便使用restful web服务并从这些web服务中每N秒获得一些响应。在WSO2 ESB的任务配置页面中,配置SOAP服务很简单,但是REST服务呢?例如,如果我想向这个web服务http://maps.googleapis.com/maps询问一些信息,我如何配置工作任务?

从任务中,您可以通过序列或代理服务将消息注入RESTful端点。有关如何做到这一点的更多细节,请参阅[1]的Injecting messages to RESTful Endpoints部分。

[1] https://docs.wso2.com/display/ESB481/Adding +和+计划+任务

首先,您需要定义一个序列来调用REST端点并向其注入计划任务。试试下面的例子:

<sequence xmlns="http://ws.apache.org/ns/synapse" name="callAPI">
   <call>
      <endpoint>
         <http method="GET" uri-template="http://testAPI/test"/>
      </endpoint>
   </call>
</sequence>

<task xmlns="http://ws.apache.org/ns/synapse"
      name="testTask"
      class="org.apache.synapse.startup.tasks.MessageInjector"
      group="synapse.simple.quartz">
   <trigger interval="5"/>
   <property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
             name="sequenceName"
             value="callAPI"/>
   <property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
             name="injectTo"
             value="sequence"/>
   <property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="message">
      <test xmlns=""/>
   </property>
</task>

最新更新