注释ActivationConfigProperty所需的替代方法

时间:2018-01-24 13:44:58

标签: jms jboss6.x message-driven-bean

我在JBoss eap上有一个MDB。我想要的是从我的java代码注册队列。如果一个人不想使用注释,我所能找到的就是使用ejb-jar.xml。那么有什么方法可以从Java代码提供目标和目标类型,比如我的java代码将从属性文件中读取。提前谢谢。

@MessageDriven(messageListenerInterface=MessageListener.class, 
        activationConfig = {
          @ActivationConfigProperty( propertyName = "destinationType", 
                                     propertyValue = "javax.jms.Queue"),
          @ActivationConfigProperty( propertyName = "destination", 
                                     propertyValue ="test_in")
       }
        )

1 个答案:

答案 0 :(得分:0)

您可以在注释本身的系统属性中设置MDB的属性值。

将注释设置为 -

@ActivationConfigProperty( propertyName = "destination", propertyValue ="${destination.queue.name}")

并将destination.queue.name定义为jboss standalone.xml -

中的系统属性
<system-properties>
        <property name="destination.queue.name" value="xx.xx.xx.xx"/>
</system-properties>

确保在服务器配置文件中启用了属性替换,并且将使用作为系统属性提供的值部署MDB。