HornetQ - 远程托管JMS服务器和队列时的ConnectionFactory异常

时间:2011-12-23 22:57:41

标签: jms jndi hornetq

我正在尝试运行HornetQ 2.2.5最终版本附带的Queue示例代码。路径是$ INSTALL_ROOT / examples / jms / queue。

当我在localhost上运行所有内容时,此示例正常工作。但是,当我更改配置以使JMS服务器位于远程主机上时,我从HornetQConnectionFactory收到会话错误。客户端在远程主机上找到JNDI服务,但在尝试建立JMS连接时失败。以下是错误堆栈。

$ ./build.sh runRemote
...
runExample:
     [java] serverProps = -XX:+UseParallelGC -Xms256M -Xmx256M -XX:+AggressiveOpts
            -XX:+UseFastAccessorMethods -Dcom.sun.management.jmxremot   
         -Djava.util.logging.config.file=/ecm/packages/hornetq-2.2.5.Final/examples/common/config
         /logging.properties
         -Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
          -Djava.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces 
     [java] Dec 22, 2011 5:54:42 PM org.hornetq.common.example.HornetQExample run
     [java] INFO: hornetq.example.runServer is false
     [java] Dec 22, 2011 5:54:42 PM org.hornetq.common.example.HornetQExample getContext
     [java] INFO: using server0/client-jndi.properties for jndi
     [java] Dec 22, 2011 5:54:43 PM org.hornetq.core.logging.impl.JULLogDelegate warn
     [java] WARNING: Tried 1 times to connect. Now giving up on reconnecting it.
     [java] javax.jms.JMSException: Failed to create session factory
     [java]     at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:615)
     [java]     at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:121)
     [java]     at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:116)
     [java]     at org.hornetq.jms.example.QueueExample.runExample(QueueExample.java:55)
     [java]     at org.hornetq.common.example.HornetQExample.run(HornetQExample.java:76)
     [java]     at org.hornetq.jms.example.QueueExample.main(QueueExample.java:35)
     [java] Caused by: HornetQException[errorCode=2 message=Cannot connect to server(s). Tried with all available servers.]
     [java]     at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:619)
     [java]     at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:611)
     [java]     ... 5 more
     [java] 
     [java] #####################
     [java] ###    FAILURE!   ###
     [java] #####################
     [java] Java Result: 1

以下是托管在远程JMS服务器上的hornetq-jms.xml配置文件。

<configuration xmlns="urn:hornetq"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
   <!--the connection factory used by the example-->
   <connection-factory name="ConnectionFactory">
      <connectors>
         <connector-ref connector-name="netty-connector"/>
      </connectors>
      <entries>
         <entry name="/ConnectionFactory"/>
      </entries>
   </connection-factory>

   <!--the queue used by the example-->
   <queue name="exampleQueue">
      <entry name="/queue/exampleQueue"/>
   </queue>
</configuration>

以下是远程JMS服务器上的hornetq-configuration.xml配置文件。

<configuration xmlns="urn:hornetq"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">

   <!-- Connectors -->

   <connectors>
      <connector name="netty-connector">
         <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
         <param key="host"  value="${hornetq.remoting.netty.host:localhost}"/>
         <param key="port"  value="${hornetq.remoting.netty.port:5445}"/>
      </connector>
   </connectors>

   <!-- Acceptors -->
   <acceptors>
      <acceptor name="netty-acceptor">
         <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>        
         <param key="host"  value="${hornetq.remoting.netty.host:0.0.0.0}"/>

      </acceptor>
   </acceptors>

   <!-- Other config -->

   <security-settings>
      <!--security for example queue-->
      <security-setting match="jms.queue.exampleQueue">
         <permission type="createDurableQueue" roles="guest"/>
         <permission type="deleteDurableQueue" roles="guest"/>
         <permission type="createNonDurableQueue" roles="guest"/>
         <permission type="deleteNonDurableQueue" roles="guest"/>
         <permission type="consume" roles="guest"/>
         <permission type="send" roles="guest"/>
      </security-setting>
   </security-settings>

</configuration>

当我尝试远程托管队列时,为什么示例不起作用的任何想法?

0 个答案:

没有答案