首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何设置定时任务?

如何设置定时任务?
EN

Stack Overflow用户
提问于 2012-05-23 23:33:54
回答 3查看 2.6K关注 0票数 1

在此之前,我问了一个问题。我的服务配置是:

代码语言:javascript
复制
<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 * * *.不能工作吗?谁能告诉我如何设置这个计划任务?

代码语言:javascript
复制
SimpleQuartz Server name not in pinned servers list. Not starting Task

我也不知道如何设置“固定服务器”。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-05-24 17:31:46

让我解释一下WSO2企业服务总线中的默认消息注入器任务是如何工作的。

它基本上创建具有给定属性(例如:消息有效负载、收件人地址等)的消息,并以配置的间隔将其注入到主序列中。

因此,在您的示例中,您必须更改主序列,使其能够过滤带有给定To地址或特定消息体的消息,并将其转发。

要做的最简单的事情就是更改WSO2ESB主序列中的默认筛选器,以便它将筛选您的收件人地址并将其发送到后端服务。

例如:将过滤器更改为:

代码语言:javascript
复制
<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.*" >
        ...
票数 1
EN

Stack Overflow用户

发布于 2012-05-24 22:52:54

请查看以下ESB配置

它有一个名为Test的代理和一个名为MyTask的任务,当MyTask将消息注入主序列时,我们过滤" to“属性,如果它是我们从任务中设置的值,则将其发送到代理服务。

配置:

代码语言:javascript
复制
<?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>
票数 1
EN

Stack Overflow用户

发布于 2012-05-26 12:17:51

您的cron表达式中有一个问题。请参考http://www.quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10723271

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档