在此之前,我问了一个问题。我的服务针叶是:
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="UnpayBilling_Task"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<class name="com.coship.mediator.UnpayBillingMediator"></class>
<log level="full" />
</inSequence>
<outSequence>
<log level="full" />
<send />
</outSequence>
<endpoint>
<address uri="http://172.21.13.153:18080/aaa/services/receiveMsg" />
</endpoint>
</target>
</proxy>
我编写了一个扩展调解器UnpayBillingMediator
交易文件。该类返回文件名并将请求发送到服务http://172.21.13.153:18080/aaa/services/receiveMsg
。服务无输入消息。我希望每天在 13:30 运行服务。我尝试添加新的计划任务。 soapAction:urn:mediate,to:http://localhost:8280/services/UnpayBilling?wsdl, Cron: 30 13 * * *.
但是它不能工作吗?任何人都可以告诉我如何设置此计划任务?
SimpleQuartz Server name not in pinned servers list. Not starting Task
我也不知道如何设置"固定服务器"。
让我解释一下默认消息注入器任务在 WSO2 ESB 中是如何工作的。
它基本上创建具有给定属性的消息(例如:消息有效负载,地址等),并以配置的间隔将其注入主序列。
因此,在您的情况下,您必须更改主序列,以便过滤具有给定To
地址或特定消息正文的消息并将其向前发送。
最简单的方法是更改主序列中的默认过滤器WSO2ESB以便它将过滤您的收件人地址并将其发送到后端服务。
例如:将过滤器更改为:
<filter xmlns:ns="http://org.apache.synapse/xsd
xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"
xmlns:ns3="http://org.apache.synapse/xsd"
source="get-property('To')"
regex="http://localhost:8280/services/UnpayBilling.*" >
...
您的 cron 表达式中存在问题。请参考 http://www.quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger
请查看以下 ESB 配置
它得到了一个名为 Test 的代理和一个名为 MyTask 的任务,当 MyTask 将消息注入主序列时,我们过滤"To"属性,如果它是我们从 Task 设置的值,则将其发送到代理服务。
配置 :
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://ws.apache.org/ns/synapse">
<registry provider="org.wso2.carbon.mediation.registry.WSO2Registry">
<parameter name="cachableDuration">15000</parameter>
</registry>
<proxy name="Test" transports="https http" startOnLoad="true" trace="disable">
<target>
<inSequence>
<log level="full">
<property name="IN" value="IN"/>
</log>
<drop/>
</inSequence>
</target>
</proxy>
<sequence name="fault">
<log level="full">
<property name="MESSAGE" value="Executing default 'fault' sequence"/>
<property xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns3="http://org.apache.synapse/xsd" name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
<property xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns3="http://org.apache.synapse/xsd" name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
</log>
<drop/>
</sequence>
<sequence name="main">
<in>
<filter xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns3="http://org.apache.synapse/xsd" source="get-property('To')" regex="http://localhost:8280/services/Test">
<then>
<send>
<endpoint>
<address uri="http://localhost:8280/services/Test"/>
</endpoint>
</send>
</then>
<else/>
</filter>
</in>
<out>
<drop/>
</out>
<description>The main sequence for the message mediation</description>
</sequence>
<task name="MyTask" class="org.apache.synapse.startup.tasks.MessageInjector" group="synapse.simple.quartz">
<trigger count="1" interval="4"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="to" value="http://localhost:8280/services/Test"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="message">
<msg xmlns="">FROM_TASK</msg>
</property>
</task>
</definitions>