当我的Webapp在JBOSS 6.0中启动时,如何确保大黄蜂队列在那里? [英] How can I ensure that the hornet queues are there when my webapp starts in JBOSS 6.0?

查看:74
本文介绍了当我的Webapp在JBOSS 6.0中启动时,如何确保大黄蜂队列在那里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上一个标题为:

如何使用Spring在JBOSS 6中获得对队列的JNDI引用?

我这样配置了一个JMS队列,该队列位于文件mytopic-hornetq-jms.xml中:

I configured a JMS queue like this, which is in a file mytopic-hornetq-jms.xml:

<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns="urn:hornetq"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
    <topic name="mytopic">
        <entry name="mytopic"/>
    </topic>
</configuration>

我的applicationContext.xml看起来像这样:

My applicationContext.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jee 
http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

    <jee:jndi-lookup id="jmsConnectionFactory" jndi-name="java:/JmsXA" />
    <jee:jndi-lookup id="jmsDestination" jndi-name="mytopic" expected-type="javax.jms.Topic" />
</beans>

这是使用JMX控制台org.jboss.naming.JNDIView的输出:

This is the output using the JMX Console org.jboss.naming.JNDIView:

  +- UserTransactionSessionFactory (proxy: $Proxy103 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
  +- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)
  +- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory)
  +- SecureDeploymentManager (class: org.jnp.interfaces.NamingContext)
  |   +- remote[link -> DeploymentManager] (class: javax.naming.LinkRef)
  +- SecureManagementView (class: org.jnp.interfaces.NamingContext)
  |   +- remote[link -> ManagementView] (class: javax.naming.LinkRef)
  +- mytopic (class: org.hornetq.jms.client.HornetQTopic)
  +- DeploymentManager (class: org.jboss.aop.generatedproxies.AOPProxy$4)
  +- XAConnectionFactory (class: org.hornetq.jms.client.HornetQConnectionFactory)
  +- ProfileService (class: org.jboss.aop.generatedproxies.AOPProxy$2)
  +- SecureProfileService (class: org.jnp.interfaces.NamingContext)
  |   +- remote[link -> ProfileService] (class: javax.naming.LinkRef)
  +- queue (class: org.jnp.interfaces.NamingContext)
  |   +- DLQ (class: org.hornetq.jms.client.HornetQQueue)
  |   +- ExpiryQueue (class: org.hornetq.jms.client.HornetQQueue)
  +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
  +- ConnectionFactory (class: org.hornetq.jms.client.HornetQConnectionFactory)
  +- jmx (class: org.jnp.interfaces.NamingContext)
  |   +- invoker (class: org.jnp.interfaces.NamingContext)
  |   |   +- RMIAdaptor (class: javax.management.MBeanServerConnection)
  |   +- rmi (class: org.jnp.interfaces.NamingContext)
  |   |   +- RMIAdaptor (class: javax.management.MBeanServerConnection)
  +- BeanValidatorFactories (class: org.jnp.interfaces.NamingContext)
  +- TomcatAuthenticators (class: java.util.Properties)
  +- XAThroughputConnectionFactory (class: org.hornetq.jms.client.HornetQConnectionFactory)
  +- ManagementView (class: org.jboss.aop.generatedproxies.AOPProxy$3)
  +- ThroughputConnectionFactory (class: org.hornetq.jms.client.HornetQConnectionFactory)

在我的书中,这意味着该主题已绑定到JNDI名称"mytopic"

which in my book means, the topic is bound to the JNDI name "mytopic"

尽管如此,Spring还是会抛出

Nevertheless does Spring throw

18:45:29,636 ERROR [ContextLoader] Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsDestination': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: mytopic not bound
...
Caused by: javax.naming.NameNotFoundException: mytopic not bound
  at org.jnp.server.NamingServer.getBinding(NamingServer.java:771) [:5.0.5.Final]
  at org.jnp.server.NamingServer.getBinding(NamingServer.java:779) [:5.0.5.Final]
  at org.jnp.server.NamingServer.getObject(NamingServer.java:785) [:5.0.5.Final]
  at org.jnp.server.NamingServer.lookup(NamingServer.java:443) [:5.0.5.Final]

更新

看起来,查找JNDI参考实际上不是问题,但实际上,在应用程序启动时未配置大黄蜂队列.

It seems, that it is not actually a problem looking up the JNDI reference, but actually that the hornet queues are not configured at the time when the application starts.

如果我稍后再部署该应用程序,它将运行良好,因为此时已配置了 大黄蜂队列.

If I deploy the application some time later, it will run just fine, because at this time the hornet queues are configured.

是否有一种方法可以指定在队列进入队列后才启动应用程序,或者是jboss在启动其余队列之前可以保留部署的配置选项?

Is there a way to specify that the application will not start untill the queues are, or is the a configuration option for the jboss to hold of deployment until the rest is started?

推荐答案

我成功地在Jboss 4.2中采用了依赖"机制.使用它,您可以指定某些内容取决于其他内容(使用xml描述符或对于ejb3,您可以使用注释).这是一个链接,可帮助您开始

I have succesfully employed the "depends" mechanism in Jboss 4.2. With it you can specify that something depends on something else (either using xml descriptors or for ejb3 you can use annotations). Here is a link to get you started

这篇关于当我的Webapp在JBOSS 6.0中启动时,如何确保大黄蜂队列在那里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆