HornetQ Topic to Topic bridge drop messages

时间:2013-05-01 20:02:05

标签: jms hornetq

我在HornetQ(related to earlier question)设置主题桥时遇到了麻烦。这个想法是这样的:

  • 通知发布到HornetQ服务器A上的主题
  • 此通知通过核心网桥发送到HornetQ服务器B上的主题
  • 客户端应用从服务器B获取通知。

我现在遇到的问题是,如果服务器B关闭,通知就会被删除。我会使用队列,但我们需要其他订阅者。我希望这个桥是持久的,并且消息将成为服务器B上的主题。我设置的方式是在hornetq-configuration.xml中:

<queues>
    <queue name="jms.topic.topic.dat.cds.internal">
        <address>jms.topic.topic.dat.cds.internal</address>
    </queue>
</queues>

<bridges>
    <bridge name="cds-bridge">
        <queue-name>jms.topic.topic.dat.cds.internal</queue-name>
        <forwarding-address>jms.topic.topic.dat.cds</forwarding-address>
        <reconnect-attempts>-1</reconnect-attempts>
        <use-duplicate-detection>true</use-duplicate-detection>
        <static-connectors>
            <connector-ref>remote-connector</connector-ref>
        </static-connectors>
    </bridge>
</bridges>

仅当两个服务器都启动时才有效。

有没有办法让这座桥成为耐用的用户?有什么我想念的吗?

[编辑 - 解决方案] - 这是有效的。诀窍是主题名称必须相同。

<queues>
    <queue name="jms.topic.topic.dat.cds">
    <address>jms.topic.topic.dat.cds</address>
</queue>

<bridges>
<bridge name="cds-bridge">
    <queue-name>jms.topic.topic.dat.cds</queue-name>
    <forwarding-address>jms.topic.topic.dat.cds</forwarding-address>
    <reconnect-attempts>-1</reconnect-attempts>
    <use-duplicate-detection>true</use-duplicate-detection>
    <static-connectors>
        <connector-ref>remote-connector</connector-ref>
    </static-connectors>
</bridge>
</bridges>

1 个答案:

答案 0 :(得分:0)

假设您有主题jms.topic.SomeTopic

您可以创建核心队列:

<queues>
    <queue name="SomeTopicBridge">
        <address>jms.topic.SomeTopic</address>
    </queue>
</queues>

请注意,Bridge Queue上的地址与您的主题名称相同。

HornetQ上的持久订阅只是主题地址的核心队列。

这样,在您重新启动目标服务器之前,该消息将等待激活。

如果这不能解答您的问题,请向我提供更多详细信息,我会发布编辑此答案,以便更好地解决您的问题。

在你的情况下,你的地址应该是这样的:

<queues>
    <queue name="cds-bridge-queue">
        <address>jms.topic.topic.dat.cds</address>
    </queue>
</queues>

通过此操作,您将在主题地址上创建核心队列,即使网桥处于脱机状态,此核心队列也将接收发送到主题的所有消息。