Anypoint Studio Quartz端点轮询数据库

时间:2014-10-27 16:16:48

标签: java mule quartz-scheduler polling endpoint

我找不到关于如何安排Quartz轮询数据库中的表的真正教程。

我试图单独检查,但它向我提供了JDBC关联类端点上的“已弃用”括号。

所以我有点迷失...如何配置一个石英来调用在Mule项目中创建的类,每次调度程序超时时都必须执行该类?

如何解析结果?

很抱歉,如果我要求很多东西,但我被卡住了......

编辑:

这是使用全局连接器的尝试:

<?xml version="1.0" encoding="UTF-8"?> 
<mule xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc"
    xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:servlet="http://www.mulesoft.org/schema/mule/servlet"
    xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.5.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/jdbc/current/mule-jdbc-ee.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd
http://www.mulesoft.org/schema/mule/servlet http://www.mulesoft.org/schema/mule/servlet/current/mule-servlet.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd">
    <db:oracle-config name="Oracle_Global_Connector"
        host="laaaaaaaaaaaaaaaaa.bbbbbbbbbb.yyyy.it" port="1521" instance="IEEEEE"
        user="HTTTTTTTTT" password="HHHHHHHHHH" doc:name="Oracle Configuration" />


    <jdbc-ee:connector name="Database_Global"
        dataSource-ref="Oracle_Global_Connector" validateConnections="true" queryTimeout="-1"
        pollingFrequency="0" doc:name="Database">
        <jdbc-ee:query key="RetriveQuery" value="select * from MyTable" />
    </jdbc-ee:connector>


    <quartz:connector name="AWB_Quartz_Poller"
        validateConnections="true" doc:name="Quartz">
        <quartz:factory-property key="org.quartz.scheduler.instanceName"
            value="MuleScheduler1" />
        <quartz:factory-property key="org.quartz.threadPool.class"
            value="org.quartz.simpl.SimpleThreadPool" />
        <quartz:factory-property key="org.quartz.threadPool.threadCount"
            value="3" />
        <quartz:factory-property key="org.quartz.scheduler.rmi.proxy"
            value="false" />
        <quartz:factory-property key="org.quartz.scheduler.rmi.export"
            value="false" />
        <quartz:factory-property key="org.quartz.jobStore.class"
            value="org.quartz.simpl.RAMJobStore" /> <!-- Optional -->
    </quartz:connector>


    <flow name="testquartzFlow1" doc:name="testquartzFlow1">
        <quartz:inbound-endpoint jobName="MyFirstQuartzScheduler"
            repeatInterval="10000" responseTimeout="10000" doc:name="QuartzInbound">
            <quartz:event-generator-job groupName="TestScheduler"
                jobGroupName="TestScheduler">
                <quartz:payload>This is a job scheduler that will write to file
                    after every 10 seconds.</quartz:payload>
            </quartz:event-generator-job>
        </quartz:inbound-endpoint>
        <jdbc-ee:outbound-endpoint exchange-pattern="request-response"
            queryKey="RetriveQuery" queryTimeout="-1" connector-ref="Database_Global"
            doc:name="Database (JDBC)" />
    </flow> 
</mule>

感谢

1 个答案:

答案 0 :(得分:0)

这是一个使用quartz的示例..它将在每10秒后轮询数据库..并且不用担心“已弃用”括号..它将起作用

  <spring:beans>
   <spring:bean id="DB_Source" name="DB_Source" class="org.enhydra.jdbc.standard.StandardDataSource">
      <spring:property name="url" value="Your DBURL"/>
      <spring:property name="driverName" value="Your Driver name"/>
    </spring:bean>
  </spring:beans>

  <jdbc-ee:connector name="Database_Global" dataSource-ref="DB_Source" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database">
   <jdbc-ee:query key="RetriveQuery" value="Select * from TableName "/>
</jdbc-ee:connector>


<quartz:connector name="AWB_Quartz_Poller" validateConnections="true" doc:name="Quartz">
   <quartz:factory-property key="org.quartz.scheduler.instanceName" value="MuleScheduler1"/>
    <quartz:factory-property key="org.quartz.threadPool.class" value="org.quartz.simpl.SimpleThreadPool"/>
   <quartz:factory-property key="org.quartz.threadPool.threadCount" value="3"/>
   <quartz:factory-property key="org.quartz.scheduler.rmi.proxy" value="false"/>
    <quartz:factory-property key="org.quartz.scheduler.rmi.export" value="false"/>
    <quartz:factory-property key="org.quartz.jobStore.class" value="org.quartz.simpl.RAMJobStore"/> <!-- Optional -->
   </quartz:connector>


 <flow name="TestScheduleServiceFlow1" doc:name="TestScheduleServiceFlow1">
  <quartz:inbound-endpoint jobName="MyFirstQuartzScheduler" repeatInterval="10000" responseTimeout="10000" connector-ref="AWB_Quartz_Poller" doc:name="QuartzInbound">
 <quartz:event-generator-job groupName="TestScheduler" jobGroupName="TestScheduler">
  <quartz:payload>This is a job scheduler that will write to file after every 10 seconds.</quartz:payload>
 </quartz:event-generator-job>
 </quartz:inbound-endpoint>
 <jdbc-ee:outbound-endpoint exchange-pattern="request-response" queryKey="RetriveQuery" queryTimeout="-1" connector-ref="Database_Global" doc:name="Database (JDBC)"/>
 </flow>
 </mule>