两个 HornetQ 服务器之间的 HornetQ JMS 桥无法交付
(编辑于 11.11.11,编辑在底部)
我有两台运行 HornetQ(版本 2.2.5 AS7)服务器的 JBoss AS 6.1 服务器。 让我们称另一位为客户,另一位为大师。
CLIENT 有一个队列(“sourceQueue”),由我们的 Web 应用程序写入。
CLIENT和MASTER服务器之间建立了一个JMS桥, 它消耗来自 CLIENT 上的 sourceQueue 的消息并应在 MASTER 上的 targetQueue。该桥在客户端 JBoss 上运行。
问题:表面上似乎没有发生任何事情,而不是从源消费并在目标上生成消息:源有 1 条消息,目标没有消息。也有可能源头正在一遍又一遍地接收该消息。
使用 netty 连接器的网络连接正在工作,这已经通过重新启动网桥并观察 netstat -n -c 输出进行了测试。
什么样的问题可能会导致此类问题?
- 网络问题?
- 交易经理?
- 连接器错误?
您将如何诊断 HornetQ 桥接器的问题?
下面是 hornetq-jboss-beans.xml 上的网桥定义(在 CLIENT /jboss/server/default/deploy/hornetq 上)。定义是 HornetQ 手册:
<bean name="JMSBridge" class="org.hornetq.jms.bridge.impl.JMSBridgeImpl">
<!-- HornetQ must be started before the bridge -->
<depends>HornetQServer</depends>
<constructor>
<!-- Source ConnectionFactory Factory -->
<parameter>
<inject bean="SourceCFF"/>
</parameter>
<!-- Target ConnectionFactory Factory -->
<parameter>
<inject bean="TargetCFF"/>
</parameter>
<!-- Source DestinationFactory -->
<parameter>
<inject bean="SourceDestinationFactory"/>
</parameter>
<!-- Target DestinationFactory -->
<parameter>
<inject bean="TargetDestinationFactory"/>
</parameter>
<!-- Source User Name (no username here) -->
<parameter><null /></parameter>
<!-- Source Password (no password here)-->
<parameter><null /></parameter>
<!-- Target User Name (no username here)-->
<parameter><null /></parameter>
<!-- Target Password (no password here)-->
<parameter><null /></parameter>
<!-- Selector -->
<parameter><null /></parameter>
<!-- Failure Retry Interval (in ms) -->
<parameter>5000</parameter>
<!-- Max Retries -->
<parameter>10</parameter>
<!-- Quality Of Service -->
<parameter>ONCE_AND_ONLY_ONCE</parameter>
<!-- Max Batch Size -->
<parameter>1</parameter>
<!-- Max Batch Time (-1 means infinite) -->
<parameter>-1</parameter>
<!-- Subscription name (no subscription name here)-->
<parameter><null /></parameter>
<!-- Client ID (no client ID here)-->
<parameter><null /></parameter>
<!-- Add MessageID In Header -->
<parameter>true</parameter>
<!-- register the JMS Bridge in the AS MBeanServer -->
<parameter>
<inject bean="MBeanServer"/>
</parameter>
<parameter>org.hornetq:service=MyJMSBridge</parameter>
</constructor>
<property name="transactionManager">
<inject bean="RealTransactionManager"/>
</property>
</bean>
<!-- SourceCFF describes the ConnectionFactory used to connect to the
source destination -->
<bean name="SourceCFF"
class="org.hornetq.jms.bridge.impl.JNDIConnectionFactoryFactory">
<constructor>
<parameter>
<inject bean="sourceJNDI" />
</parameter>
<parameter>/XAConnectionFactory</parameter>
</constructor>
</bean>
<!-- TargetCFF describes the ConnectionFactory used to connect to the
target destination -->
<bean name="TargetCFF"
class="org.hornetq.jms.bridge.impl.JNDIConnectionFactoryFactory">
<constructor>
<parameter>
<inject bean="targetJNDI" />
</parameter>
<parameter>/integration/XAConnectionFactory</parameter>
</constructor>
</bean>
<!-- SourceDestinationFactory describes the Destination used as the source -->
<bean name="SourceDestinationFactory"
class="org.hornetq.jms.bridge.impl.JNDIDestinationFactory">
<constructor>
<parameter>
<inject bean="sourceJNDI"/>
</parameter>
<parameter>/jms/notificationRequestQueue</parameter>
</constructor>
</bean>
<!-- TargetDestinationFactory describes the Destination used as the target -->
<bean name="TargetDestinationFactory"
class="org.hornetq.jms.bridge.impl.JNDIDestinationFactory">
<constructor>
<parameter>
<inject bean="targetJNDI" />
</parameter>
<parameter>/integration/jms/notificationRequestQueue</parameter>
</constructor>
</bean>
<!-- JNDI is a Hashtable containing the JNDI properties required -->
<!-- to connect to the sources and targets JMS resrouces -->
<bean name="sourceJNDI" class="java.util.Hashtable">
<constructor class="java.util.Map">
<map class="java.util.Hashtable" keyClass="java.lang.String"
valueClass="java.lang.String">
<entry>
<key>java.naming.factory.initial</key>
<value>org.jnp.interfaces.NamingContextFactory</value>
</entry>
<entry>
<key>java.naming.provider.url</key>
<value>jnp://localhost:1099</value>
</entry>
<entry>
<key>java.naming.factory.url.pkgs</key>
<value>org.jboss.naming:org.jnp.interfaces"</value>
</entry>
<entry>
<key>jnp.timeout</key>
<value>5000</value>
</entry>
<entry>
<key>jnp.sotimeout</key>
<value>5000</value>
</entry>
</map>
</constructor>
</bean>
<bean name="targetJNDI" class="java.util.Hashtable">
<constructor class="java.util.Map">
<map class="java.util.Hashtable" keyClass="java.lang.String"
valueClass="java.lang.String">
<entry>
<key>java.naming.factory.initial</key>
<value>org.jnp.interfaces.NamingContextFactory</value>
</entry>
<entry>
<key>java.naming.provider.url</key>
<value>jnp://TARGET-URL.example.com:1099</value>
</entry>
<entry>
<key>java.naming.factory.url.pkgs</key>
<value>org.jboss.naming:org.jnp.interfaces"</value>
</entry>
<entry>
<key>jnp.timeout</key>
<value>5000</value>
</entry>
<entry>
<key>jnp.sotimeout</key>
<value>5000</value>
</entry>
</map>
</constructor>
</bean>
CLIENT 端 hornetq-jms.xml 上的队列定义:
<configuration xmlns="urn:hornetq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
<connection-factory name="NettyConnectionFactory">
<connectors>
<connector-ref connector-name="netty"/>
</connectors>
<entries>
<entry name="/ConnectionFactory"/>
<entry name="/XAConnectionFactory"/>
</entries>
<xa>true</xa>
</connection-factory>
<queue name="DLQ">
<entry name="/queue/DLQ"/>
</queue>
<queue name="ExpiryQueue">
<entry name="/queue/ExpiryQueue"/>
</queue>
<queue name="notificationQueue">
<entry name="/jms/notificationRequestQueue"/>
</queue>
</configuration>
以及 MASTER 端 hornetq-jms.xml 上的队列定义:
<configuration xmlns="urn:hornetq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
<connection-factory name="NettyConnectionFactory">
<connectors>
<connector-ref connector-name="netty"/>
</connectors>
<entries>
<entry name="/ConnectionFactory"/>
<entry name="/XAConnectionFactory"/>
</entries>
<xa>true</xa>
</connection-factory>
<connection-factory name="NettyRemoteConnectionFactory">
<connectors>
<connector-ref connector-name="netty-remote"/>
</connectors>
<entries>
<entry name="/integration/XAConnectionFactory"/>
</entries>
<xa>true</xa>
</connection-factory>
<queue name="DLQ">
<entry name="/queue/DLQ"/>
</queue>
<queue name="ExpiryQueue">
<entry name="/queue/ExpiryQueue"/>
</queue>
<queue name="targetQueue">
<entry name="/integration/jms/notificationRequestQueue"/>
</queue>
<topic name="unrelatedTopic">
<entry name="/topic/cacheFlushNotification"/>
</topic>
</configuration>
编辑: 由于某种原因,如果我在两台服务器完全部署后停止并重新启动桥,桥就会开始传输消息。这是一个手动过程,我讨厌使用 hack 来定期重新启动桥。我欢迎对此问题提出任何建议。
我还通过使桥依赖于它从中读取的队列来改进启动顺序 - 否则桥在队列之前启动,导致记录错误。
(Edited on 11.11.11, edits at bottom)
I have two JBoss AS 6.1 servers running HornetQ (version 2.2.5 AS7) servers.
Lets call the other one CLIENT and other one MASTER.
CLIENT has a Queue ("sourceQueue"), which is written to by our web application.
There is a JMS bridge set up between CLIENT and MASTER servers,
which consumes messages from sourceQueue on CLIENT and should produce them on
the targetQueue on MASTER. The bridge is running on the CLIENT JBoss.
PROBLEM: Instead of consuming from source and producing messages on target, superficially nothing seems to happen: the source has 1 message, target has none. It is also possible that the source is being fed that message over and over.
Network connection using netty connectors is working, this has been tested restarting the bridge and observing the netstat -n -c output.
What kind of issues could cause this kind of problems?
- Network issues?
- Transaction manager?
- Connector errors?
How would you go about diagnosing problems with HornetQ bridge?
Below is the bridge definition on hornetq-jboss-beans.xml (on CLIENT /jboss/server/default/deploy/hornetq ). Definition is close variation of the JMS bridge example on HornetQ manual:
<bean name="JMSBridge" class="org.hornetq.jms.bridge.impl.JMSBridgeImpl">
<!-- HornetQ must be started before the bridge -->
<depends>HornetQServer</depends>
<constructor>
<!-- Source ConnectionFactory Factory -->
<parameter>
<inject bean="SourceCFF"/>
</parameter>
<!-- Target ConnectionFactory Factory -->
<parameter>
<inject bean="TargetCFF"/>
</parameter>
<!-- Source DestinationFactory -->
<parameter>
<inject bean="SourceDestinationFactory"/>
</parameter>
<!-- Target DestinationFactory -->
<parameter>
<inject bean="TargetDestinationFactory"/>
</parameter>
<!-- Source User Name (no username here) -->
<parameter><null /></parameter>
<!-- Source Password (no password here)-->
<parameter><null /></parameter>
<!-- Target User Name (no username here)-->
<parameter><null /></parameter>
<!-- Target Password (no password here)-->
<parameter><null /></parameter>
<!-- Selector -->
<parameter><null /></parameter>
<!-- Failure Retry Interval (in ms) -->
<parameter>5000</parameter>
<!-- Max Retries -->
<parameter>10</parameter>
<!-- Quality Of Service -->
<parameter>ONCE_AND_ONLY_ONCE</parameter>
<!-- Max Batch Size -->
<parameter>1</parameter>
<!-- Max Batch Time (-1 means infinite) -->
<parameter>-1</parameter>
<!-- Subscription name (no subscription name here)-->
<parameter><null /></parameter>
<!-- Client ID (no client ID here)-->
<parameter><null /></parameter>
<!-- Add MessageID In Header -->
<parameter>true</parameter>
<!-- register the JMS Bridge in the AS MBeanServer -->
<parameter>
<inject bean="MBeanServer"/>
</parameter>
<parameter>org.hornetq:service=MyJMSBridge</parameter>
</constructor>
<property name="transactionManager">
<inject bean="RealTransactionManager"/>
</property>
</bean>
<!-- SourceCFF describes the ConnectionFactory used to connect to the
source destination -->
<bean name="SourceCFF"
class="org.hornetq.jms.bridge.impl.JNDIConnectionFactoryFactory">
<constructor>
<parameter>
<inject bean="sourceJNDI" />
</parameter>
<parameter>/XAConnectionFactory</parameter>
</constructor>
</bean>
<!-- TargetCFF describes the ConnectionFactory used to connect to the
target destination -->
<bean name="TargetCFF"
class="org.hornetq.jms.bridge.impl.JNDIConnectionFactoryFactory">
<constructor>
<parameter>
<inject bean="targetJNDI" />
</parameter>
<parameter>/integration/XAConnectionFactory</parameter>
</constructor>
</bean>
<!-- SourceDestinationFactory describes the Destination used as the source -->
<bean name="SourceDestinationFactory"
class="org.hornetq.jms.bridge.impl.JNDIDestinationFactory">
<constructor>
<parameter>
<inject bean="sourceJNDI"/>
</parameter>
<parameter>/jms/notificationRequestQueue</parameter>
</constructor>
</bean>
<!-- TargetDestinationFactory describes the Destination used as the target -->
<bean name="TargetDestinationFactory"
class="org.hornetq.jms.bridge.impl.JNDIDestinationFactory">
<constructor>
<parameter>
<inject bean="targetJNDI" />
</parameter>
<parameter>/integration/jms/notificationRequestQueue</parameter>
</constructor>
</bean>
<!-- JNDI is a Hashtable containing the JNDI properties required -->
<!-- to connect to the sources and targets JMS resrouces -->
<bean name="sourceJNDI" class="java.util.Hashtable">
<constructor class="java.util.Map">
<map class="java.util.Hashtable" keyClass="java.lang.String"
valueClass="java.lang.String">
<entry>
<key>java.naming.factory.initial</key>
<value>org.jnp.interfaces.NamingContextFactory</value>
</entry>
<entry>
<key>java.naming.provider.url</key>
<value>jnp://localhost:1099</value>
</entry>
<entry>
<key>java.naming.factory.url.pkgs</key>
<value>org.jboss.naming:org.jnp.interfaces"</value>
</entry>
<entry>
<key>jnp.timeout</key>
<value>5000</value>
</entry>
<entry>
<key>jnp.sotimeout</key>
<value>5000</value>
</entry>
</map>
</constructor>
</bean>
<bean name="targetJNDI" class="java.util.Hashtable">
<constructor class="java.util.Map">
<map class="java.util.Hashtable" keyClass="java.lang.String"
valueClass="java.lang.String">
<entry>
<key>java.naming.factory.initial</key>
<value>org.jnp.interfaces.NamingContextFactory</value>
</entry>
<entry>
<key>java.naming.provider.url</key>
<value>jnp://TARGET-URL.example.com:1099</value>
</entry>
<entry>
<key>java.naming.factory.url.pkgs</key>
<value>org.jboss.naming:org.jnp.interfaces"</value>
</entry>
<entry>
<key>jnp.timeout</key>
<value>5000</value>
</entry>
<entry>
<key>jnp.sotimeout</key>
<value>5000</value>
</entry>
</map>
</constructor>
</bean>
The queue definitions on CLIENT side hornetq-jms.xml:
<configuration xmlns="urn:hornetq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
<connection-factory name="NettyConnectionFactory">
<connectors>
<connector-ref connector-name="netty"/>
</connectors>
<entries>
<entry name="/ConnectionFactory"/>
<entry name="/XAConnectionFactory"/>
</entries>
<xa>true</xa>
</connection-factory>
<queue name="DLQ">
<entry name="/queue/DLQ"/>
</queue>
<queue name="ExpiryQueue">
<entry name="/queue/ExpiryQueue"/>
</queue>
<queue name="notificationQueue">
<entry name="/jms/notificationRequestQueue"/>
</queue>
</configuration>
And on the MASTER side hornetq-jms.xml:
<configuration xmlns="urn:hornetq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
<connection-factory name="NettyConnectionFactory">
<connectors>
<connector-ref connector-name="netty"/>
</connectors>
<entries>
<entry name="/ConnectionFactory"/>
<entry name="/XAConnectionFactory"/>
</entries>
<xa>true</xa>
</connection-factory>
<connection-factory name="NettyRemoteConnectionFactory">
<connectors>
<connector-ref connector-name="netty-remote"/>
</connectors>
<entries>
<entry name="/integration/XAConnectionFactory"/>
</entries>
<xa>true</xa>
</connection-factory>
<queue name="DLQ">
<entry name="/queue/DLQ"/>
</queue>
<queue name="ExpiryQueue">
<entry name="/queue/ExpiryQueue"/>
</queue>
<queue name="targetQueue">
<entry name="/integration/jms/notificationRequestQueue"/>
</queue>
<topic name="unrelatedTopic">
<entry name="/topic/cacheFlushNotification"/>
</topic>
</configuration>
EDIT:
For some reason, the bridge starts transfering messages if I stop and restart the bridge once both servers are completely deployed. This is a manual process, and I loathe to use a hack to periodically restart the bridge. I welcome any suggestions to this issue.
I also improved the startup sequence by making the bridge depend on the queue it reads from - otherwise the bridge is started before the queue, causing errors to log.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查这个帖子:
https://issues.jboss.org/browse/HORNETQ-247
它提供了有关如何公开核心队列并在核心桥中使用它们的一些见解。
Check this post :
https://issues.jboss.org/browse/HORNETQ-247
it gives some insight about how to expose core queue and use them in core bridge.
为什么不使用核心桥?
Why don't you use a core-bridge?