2015-06-06 19 views
1

我有一個場景,我試圖從Yelp API讀取數據並希望在一定的時間間隔後將其放入ActiveMQ隊列中,所以我使用石英調度器。我的石英調度程序每隔10分鐘運行一次,並將數據推送到隊列, 一切都很好,直到這裏,在集羣環境中使用與Mule Quartz

現在我希望這在集羣環境中工作,在那裏我將部署2個實例並監聽相同的Yelp Endpoint,Now現在發生的事情是,我的2個實例的quartz調度器在同一個實例中執行,它們從Yelp中提取相同的信息,導致相同的消息在ActiveMQ隊列中出現,即DUPLICATES(我想使用集羣環境實現高可用性,即如果任何節點失敗其他節點c )

那麼是否有任何配置,在Mule中可以將一個節點提升爲主節點,並將其他節點提升爲故障轉移節點。

感謝您的幫助!

+0

您是否正在使用Mule Enterprise Edition進行羣集? –

+0

@DavidDossot現在還不行,但有沒有辦法做到這一點,使用企業版?,你可以請一些光? – Vihar

+0

是的,EE集羣負責管理羣集中的單例端點,如輪詢器。如果你不使用EE,你必須建立一些自定義的東西來做到這一點。 –

回答

3

這將通過cron表達式0/10 * * * * ?(每10秒)觸發一個運行相同應用程序並連接到相同數據庫(本例中爲MySQL)的節點。石英設置有點麻煩。你需要配置數據庫等,但我留下你研究Quartz文檔。你應該看看版本1.8.x而不是2.x.

這幾乎是Mule EE中聚類端點的預算替代方案。當你不想集羣EE節點或需要運行CE節點時,這很有用。

<?xml version="1.0" encoding="UTF-8"?> 

<mule xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" 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="EE-3.6.2" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="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/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd 
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd 
http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd"> 

    <quartz:connector name="quartzConnector" validateConnections="true" doc:name="Quartz"> 
     <quartz:factory-property key="org.quartz.scheduler.instanceName" value="QuartzScheduler" /> 
     <quartz:factory-property key="org.quartz.scheduler.instanceId" value="AUTO" /> 
     <quartz:factory-property key="org.quartz.jobStore.isClustered" value="true" /> 
     <quartz:factory-property key="org.quartz.scheduler.jobFactory.class" value="org.quartz.simpl.SimpleJobFactory" /> 
     <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.impl.jdbcjobstore.JobStoreTX" /> 
     <quartz:factory-property key="org.quartz.jobStore.driverDelegateClass" value="org.quartz.impl.jdbcjobstore.StdJDBCDelegate" /> 
     <quartz:factory-property key="org.quartz.jobStore.dataSource" value="quartzDataSource" /> 
     <quartz:factory-property key="org.quartz.jobStore.tablePrefix" value="QRTZ_" /> 

     <quartz:factory-property key="org.quartz.dataSource.quartzDataSource.driver" value="com.mysql.jdbc.Driver" /> 

     <quartz:factory-property key="org.quartz.dataSource.quartzDataSource.URL" value="jdbc:mysql://localhost:3306/qrtz" /> 
     <quartz:factory-property key="org.quartz.dataSource.quartzDataSource.user" value="root" /> 
     <quartz:factory-property key="org.quartz.dataSource.quartzDataSource.password" value="" /> 
     <quartz:factory-property key="org.quartz.dataSource.quartzDataSource.maxConnections" value="8" /> 

    </quartz:connector> 

    <flow name="cFlow1"> 
     <quartz:inbound-endpoint jobName="job1" cronExpression="0/10 * * * * ?" repeatInterval="0" connector-ref="quartzConnector" responseTimeout="10000" doc:name="Quartz"> 
      <quartz:event-generator-job> 
       <quartz:payload>Job Trigger</quartz:payload> 
      </quartz:event-generator-job> 
     </quartz:inbound-endpoint> 
     <logger level="INFO" message="Got message" doc:name="Logger"/> 
    </flow>   
</mule> 
+0

同意這是使用Quartz實現集羣的一種方法,可以與CE和Mule EE一起使用。但AFAIK Mule EE也發佈了石英社區版,所以Quartz JDBCJobStore可能是唯一的選擇。除非Mule提供Gigaspaces或jgroups的另一個集羣選項。有人可以確認。 – Ashoka

-1

我們使用3.5.2-企業版,但不確定社區版是否有限制。你可以嘗試以下方法,看看它是否有效:

<!-- Quart Connector with one thread to ensure that we don't have duplicate processing at any point of time --> 
<quartz:connector name="QuartzConnector" validateConnections="true"> 
    <receiver-threading-profile maxThreadsActive="1" /> 
</quartz:connector> 

然後在你打算觸發這個動作的任何地方參考你的流程。

<flow name="test"> 
    <quartz:inbound-endpoint jobName="myQuartzJob" cronExpression="${my.job.cron.expression}" repeatInterval="${my.job.repeat.interval}" responseTimeout="${my.job.response.timeout}" connector-ref="QuartzConnector"> 
     <quartz:event-generator-job> 
      <quartz:payload>blah</quartz:payload> 
     </quartz:event-generator-job> 
    </quartz:inbound-endpoint> 
</flow>  

希望工程。

+0

@DavidDossot是否正確地執行此操作?我有一點疑問,因爲我將擁有多個mule實例,並且分析會導致每個實例有一個活動線程 – Vihar