如何使用Quartz组件安排服务,该组件将定期调用文件上传器? [英] How to schedule a service using Quartz component that will invoke a file uploader on a periodic basis?

查看:58
本文介绍了如何使用Quartz组件安排服务,该组件将定期调用文件上传器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我上一个问题的扩展

This is an extension of my previous question How to upload multiple files via REST over HTTP using Mule?. The requirement say that, on every Wednesday at 10AM the files has to be uploaded. Henceforth I need a scheduler for accomplishing this. And I found that the solution is "Quartz" inbound component with Cron Expression.

但是我该怎么办呢?因为我不能有两个入站端点".(石英和文件)例如

But how can I do so? Because I cannot have two "inbound-endpoint".(quartz and file) e.g.

<flow name="fileUploader" doc:name="fileUploader">

    <quartz:inbound-endpoint 
        jobName="myServiceJob" 
        repeatInterval="5000" 
        cronExpression="0 0 10 ? * WED 
        doc:name="Quartz">
        <quartz:event-generator-job/>
   </quartz:inbound-endpoint>

        <file:inbound-endpoint 
            path="C:\input"
            pollingFrequency="5000" moveToDirectory="C:\movehere" doc:name="File"
            responseTimeout="10000"/>

    <object-to-byte-array-transformer doc:name="Object to Byte Array"/>

    <file:outbound-endpoint 
            path="C:\outputfile" 
            responseTimeout="10000" 
            doc:name="File"/>

</flow>

如果我跑步,我会报错

线程主"中的异常org.mule.module.launcher.DeploymentInitException:SAXParseException:cvc-complex-type.2.4.a:发现无效的内容,从元素"file:inbound-endpoint"开始. /strong>

Exception in thread "main" org.mule.module.launcher.DeploymentInitException: SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'file:inbound-endpoint'.

那我需要做什么改变?

请帮助

推荐答案

尝试一下

<file:endpoint name="fileConnector" path="C:\input" pollingFrequency="5000" doc:name="File"/>

<flow name="fileUploader" doc:name="fileUploader">

        <quartz:inbound-endpoint 
        jobName="myServiceJob" 
        repeatInterval="5000" 
        cronExpression="0 0 10 ? * WED" 
        doc:name="Quartz">

        <quartz:endpoint-polling-job>
            <quartz:job-endpoint ref="fileConnector"/>
        </quartz:endpoint-polling-job>
       </quartz:inbound-endpoint>

       <file:outbound-endpoint 
        path="C:\outputfile" 
        responseTimeout="10000"        
            outputPattern="#[message.inboundProperties.originalFilename]"       
       doc:name="File"/>
</flow>

这篇关于如何使用Quartz组件安排服务,该组件将定期调用文件上传器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆