首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >两个HornetQ服务器之间的HornetQ JMS无法传递

两个HornetQ服务器之间的HornetQ JMS无法传递
EN

Stack Overflow用户
提问于 2011-11-03 13:23:11
回答 2查看 2.7K关注 0票数 4

( 11.11.11编辑,底部编辑)

我有两个JBoss作为6.1服务器运行HornetQ (Version2.2.5 AS7)服务器。让我们给另一个客户端和另一个主程序打电话。

客户端有一个队列("sourceQueue"),它是由我们的web应用程序写入的。

在客户机和主服务器之间设置了一个JMS桥,它在客户机上使用来自sourceQueue的消息,并且应该在主服务器上的targetQueue上产生消息。桥接器正在客户端JBoss上运行。

问题:从表面上看,没有从源消费和生成目标消息,表面上似乎什么都没有发生:源有1条消息,目标没有消息。消息来源也有可能一遍又一遍地被灌输这个信息。

使用netty连接器的网络连接工作正常,这已经过测试,重新启动网桥并观察netstat -n -c的输出。

什么样的问题才能引起这种问题呢?

  • 网络问题?
  • 交易经理?
  • 连接器错误?

您将如何诊断HornetQ桥的问题?

下面是hornetq-jboss-beans.xml (在CLIENT /jboss/server/default/deploy/hornetq上)上的桥定义。定义是HornetQ手册上JMS示例的密切变化

代码语言:javascript
复制
   <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>

客户端hornetq-jms.xml上的队列定义:

代码语言:javascript
复制
<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>

在主服务器端,hornetq-jms.xml:

代码语言:javascript
复制
<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>

编辑:由于某种原因,一旦完全部署了两个服务器,如果我停止并重新启动桥,桥就会开始传递消息。这是一个手动过程,我不喜欢使用黑客定期重新启动桥。我欢迎对这一问题提出任何建议。

我还改进了启动顺序,使桥依赖于它读取的队列-否则桥会在队列之前启动,从而导致日志错误。

EN

回答 2

Stack Overflow用户

发布于 2011-12-20 14:31:52

查看这篇文章:https://issues.jboss.org/browse/HORNETQ-247,它提供了一些关于如何公开核心队列并在核心桥中使用它们的见解。

票数 2
EN

Stack Overflow用户

发布于 2011-11-11 17:29:55

你为什么不用核心桥呢?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7995625

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档