无法用Spring 3连接到JBoss 5中的HornetQ连接工厂

时间:2021-07-15 20:51:05

Locally, my application connects fine to the built in netty ConnectionFactory and I have no problems on start up or sending topic messages. My local box is stand-alone JBoss 5.1 and stand-alone HornetQ.

在本地,我的应用程序可以很好地连接到内建的netty ConnectionFactory,在启动或发送主题消息方面我没有问题。我的本地框是独立的JBoss 5.1和独立的HornetQ。

However, when deploying to our DEV server (running clustered JBoss 5.1 and clustered HornetQ) I'm not able to connect, getting the following stack trace:

但是,当部署到我们的DEV服务器(运行集群JBoss 5.1和集群HornetQ)时,我无法连接,得到以下堆栈跟踪:

ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/eShowroom]] (main) Exception sending context initialized event to listener instance of cla>\ss org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'topicConnectionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: ConnectionFactory not bound

I'm trying to use the default, built-in netty connector with no extra configuration except for my own JMS Topic. I'm relatively unaware of the DEV server setup as it is out of my control and fairly black box to me.

我正在尝试使用默认的内置netty连接器,除了我自己的JMS主题之外,没有其他配置。我对DEV服务器设置不太了解,因为它超出了我的控制范围,而且对我来说是相当黑的。

applicationContext.xml (in $JBOSS_HOME/server/default/deploy/application.war/WEB-INF):

applicationContext。xml(在$ JBOSS_HOME /服务器/默认的web - inf /部署/ application.war /):

    <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
       <property name="environment">
            <props>
                <prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>
                <prop key="java.naming.provider.url">jnp://${jboss.bind.address:localhost}:1099</prop>
                <prop key="java.naming.factory.url.pkgs">org.jboss.naming</prop>
            </props>
       </property>
    </bean>

    <bean id="topicConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate" ref="jndiTemplate"></property>
        <property name="jndiName" value="/ConnectionFactory"></property>
    </bean>

    <bean id="cacheTopic" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate" ref="jndiTemplate"></property>
        <property name="jndiName" value="/topic/myCacheTopic"></property>
    </bean>

    <bean id="jmsDestinationResolver" class="org.springframework.jms.support.destination.JndiDestinationResolver">
        <property name="jndiTemplate" ref="jndiTemplate"/>
        <property name="cache" value="true"/>
    </bean>

    <bean id="messageSendTemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory" ref="topicConnectionFactory"/>
        <property name="destinationResolver" ref="jmsDestinationResolver"/>
        <property name="pubSubDomain" value="true"/>
    </bean>

hornetq-jms.xml (in $JBOSS_HOME/server/default/deploy/hornetq.sar)

hornetq-jms。xml(在JBOSS_HOME美元/服务器/违约/部署/ hornetq.sar)

    <connection-factory name="NettyConnectionFactory">
      <xa>true</xa>
      <connectors>
         <connector-ref connector-name="netty"/>
      </connectors>
      <entries>
         <entry name="/ConnectionFactory"/>
         <entry name="/XAConnectionFactory"/>
      </entries>
   </connection-factory>

   <connection-factory name="NettyThroughputConnectionFactory">
      <xa>true</xa>
       <connectors>
         <connector-ref connector-name="netty-throughput"/>
       </connectors>
        <entries>
            <entry name="/ThroughputConnectionFactory"/>
            <entry name="/XAThroughputConnectionFactory"/>
        </entries>
    </connection-factory>

   <connection-factory name="InVMConnectionFactory">
      <xa>true</xa>
      <connectors>
         <connector-ref connector-name="in-vm"/>
      </connectors>
      <entries>
         <entry name="java:/ConnectionFactory"/>
         <entry name="java:/XAConnectionFactory"/>
      </entries>
   </connection-factory>

The only difference between local and DEV that I can easily spot is in hornetq-configuration.xml.

本地和DEV之间唯一的区别是hornetq-configuration.xml。

DEV hornetq-configuration.xml (same path as hornetq-jms.xml)

DEV hornetq-configuration。xml(与hornetq-jms.xml相同的路径)

   <broadcast-groups>
      <broadcast-group name="bg-group1">
         <group-address>${hornetq.broadcast.bg-group1.address:231.7.7.7}</group-address>
         <group-port>${hornetq.broadcast.bg-group1.port:9876}</group-port>
         <broadcast-period>5000</broadcast-period>
         <connector-ref>netty</connector-ref>
      </broadcast-group>
   </broadcast-groups>

   <discovery-groups>
      <discovery-group name="dg-group1">
         <group-address>${hornetq.discovery.dg-group1.address:231.7.7.7}</group-address>
         <group-port>${hornetq.discovery.dg-group1.port:9876}</group-port>
         <refresh-timeout>10000</refresh-timeout>
      </discovery-group>
   </discovery-groups>

   <cluster-connections>
      <cluster-connection name="my-cluster">
         <address>jms</address>  
         <connector-ref>netty</connector-ref>
          <discovery-group-ref discovery-group-name="dg-group1"/>
      </cluster-connection>
   </cluster-connections>

1 个解决方案

#1


0  

So, it turns out that for whatever reason this was a timing issue in a clustered environment. The bean(s) that needed the connection factory were simply forced to wait until everything else was up and running before spinning up.

因此,不管出于什么原因,这在集群环境中是一个时间问题。需要连接工厂的bean被简单地强制等待,直到所有其他的东西都启动并运行后才开始旋转。

#1


0  

So, it turns out that for whatever reason this was a timing issue in a clustered environment. The bean(s) that needed the connection factory were simply forced to wait until everything else was up and running before spinning up.

因此,不管出于什么原因,这在集群环境中是一个时间问题。需要连接工厂的bean被简单地强制等待,直到所有其他的东西都启动并运行后才开始旋转。