简体   繁体   English

带有JDBC MasterSlave的ActiveMQ计划程序故障转移

[英]ActiveMQ Scheduler Failover with JDBC MasterSlave

I currently have a working two-broker JDBC MasterSlave configuration, and the next step for me is to implement a scheduler with failover. 我目前有一个可用的两代理JDBC MasterSlave配置,对我来说,下一步是实现具有故障转移功能的调度程序。 I've looked around and haven't seen any information about this, and was curious to see if this is possible or if I should try a different approach. 我四处张望,没有看到任何有关此的信息,并很好奇是否可行,或者是否应该尝试其他方法。

Currently, I have the two brokers using the same dataDirectory both within the broker tag and the JDBCPersistenceAdapter tag. 当前,我有两个代理,它们在broker标记和JDBCPersistenceAdapter标记内都使用相同的dataDirectory。 However, within that data directory ActiveMQ creates two separate scheduler folders. 但是,ActiveMQ在该数据目录中创建两个单独的调度程序文件夹。 I cannot seem to force it to use the same one, so failover with scheduling isn't working. 我似乎无法强迫它使用相同的服务器,因此无法进行具有计划的故障转移。

I've also tried the KahaDB approach with the same criteria, and that doesn't seem to work either. 我还用相同的标准尝试了KahaDB方法,但这似乎也不起作用。

Another option would be for the scheduler information to be pushed to the database (in this case, oracle) and be able to be picked up from there (not sure if possible). 另一种选择是将调度程序信息推送到数据库(在本例中为oracle),并能够从那里获取(不确定是否可能)。

Here is a basic overview of what I need: 这是我需要的基本概述:

  1. Master and slave brokers up and running, using same dataDirectory (lets say, broker1 and broker2) 使用相同的dataDirectory启动和运行主代理和从代理,(例如,broker1和broker2)
  2. If I send a request to process messages through master at a certain time and master fails, slave should be able to pick up the scheduler information from master (this is where I'm stuck) 如果我在某个时间通过主服务器发送请求以处理消息,而主服务器失败,则从服务器应该能够从主服务器接收调度程序信息(这就是我遇到的问题)
  3. Slave should be processing these messages at the scheduled time 从站应该在计划的时间处理这些消息

activemq.xml (relevant parts) activemq.xml(相关部分)

<broker xmlns="http://activemq.apache.org/schema/core" brokerName="b1" useJmx="true"
    persistent="true" schedulerSupport="true">

<!-- kahaDB persistenceAdapter -->

<persistenceAdapter>
    <kahaDB directory="{activemq.data}/kahadb" enableIndexWriteAsync="false" 
    ignoreMissingJournalfiles="true" checkForCorruptJournalFiles="true"
    checksumJournalFiles="true"/> 
</persistenceAdapter>

<!-- JDBC persistenceAdapter -->

<persistenceAdapter>
    <jdbcPersistenceAdapter dataDirectory="{activemq.data}" dataSource="#oracle-ds"/>
</persistenceAdapter>

Can someone possibly point me in the right direction? 有人可以指出我正确的方向吗? I'm fairly new to ActiveMQ. 我是ActiveMQ的新手。 Thanks in advance! 提前致谢!

If anyone is curious, adding the schedulerDirectory property to the broker tag seems to be working fine. 如果有人好奇,将schedulerDirectory属性添加到broker标记似乎工作正常。 So my broker tag in activemq.xml now looks like this: 因此,activemq.xml中的我的代理标签现在看起来像这样:

<broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker1"
    dataDirectory="{activemq.data}" useJmx="true" persistent="true"
    schedulerSupport="true" schedulerDirectory="{activemq.data}/broker1/scheduler"/>

You have probably figured out what you need to do to make this work, but for the sake of other folks like me who was/is looking for the answer. 您可能已经想出了完成此工作所需要做的工作,但是为了像我这样正在寻找答案的其他人。 if you're trying to make failover work for scheduled messages with the default kahaDb store (as of v 5.13.2) and a shared file system, you will need to do the following: 如果您要使用默认的kahaDb存储(自5.13.2版开始)和共享文件系统来使计划消息的故障转移正常工作,则需要执行以下操作:

  1. Have a folder in the shared file system defined as the dataDirectory attribute in the broker tag. 在共享文件系统中有一个文件夹,该文件夹定义为broker标记中的dataDirectory属性。 /shared/folder in the example below / shared / folder在下面的示例中
  2. Use the same brokerName for all nodes in that master/slave cluster. 对该主/从集群中的所有节点使用相同的brokerName。 myBroker1 in the example below. 在下面的示例中为myBroker1。

Example: 例:

<broker xmlns="http://activemq.apache.org/schema/core" 
        brokerName="myBroker1" 
        dataDirectory="/shared/folder" 
        schedulerSupport="true">

我建议在ActiveMQ上支持问题https://issues.apache.org/jira/browse/AMQ-5238 ,因为即使您不使用计划的消息,也可以使用重新交付策略来解决计划程序问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM