3

我正在使用带有 JBoss eap 6.1 环境的 IBM MQ 消息传递提供程序开发通知服务。我能够通过 MQ JCA 提供程序 rar 即 wmq.jmsra.rar 文件成功发送消息。但是在消费者部分,我当前的配置看起来像这样

    @MessageDriven(   
    activationConfig = {   
            @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),   
            @ActivationConfigProperty(propertyName="destination", propertyValue="F2.QUEUE"),
            @ActivationConfigProperty(propertyName="providerAdapterJNDI", propertyValue="java:jboss/jms/TopicFactory"),
            @ActivationConfigProperty(propertyName="queueManager", propertyValue="TOPIC.MANAGER"),
            @ActivationConfigProperty(propertyName="hostName", propertyValue="10.239.217.242"),
            @ActivationConfigProperty(propertyName="userName", propertyValue="root"),
            @ActivationConfigProperty(propertyName = "channel", propertyValue = "TOPIC.CHANNEL"),
            @ActivationConfigProperty(propertyName = "port", propertyValue = "1422")   

    }) 

我的问题是该服务的使用者不想在这些 bean 中添加任何端口号、主机名、queueManager 属性。他们也不想使用 ejb-jar.xml 来外部化这些配置。我研究并发现我们可以添加域 IBM Message Driven Bean 但没有成功。关于我可以在这里做什么来外部化所有这些配置的任何建议?

编辑:添加--> JCA 资源适配器部署在消费者端,如果它更容易的话。

谢谢

4

2 回答 2

1

You can actually externalize an MDBs activation spec properties to the server configuration file.

Create the ejb-jar.xml file, but do not put the actual value in the file, use a property placeholder:

<activation-config-property>
    <activation-config-property-name>hostName</activation-config-property-name>
    <activation-config-property-value>${wmq.host}</activation-config-property-value>
</activation-config-property>

Do this for all of the desired properties.

Ensure that property replacement for Java EE spec files (ejb-jar.xml, in this case) is enabled in the server configuration file:

<subsystem xmlns="urn:jboss:domain:ee:1.2">
   <spec-descriptor-property-replacement>true</spec-descriptor-property-replacement>

Then, in the server configuration file, provide values for your properties:

<system-properties>
    <property name="wmq.host" value="10.0.0.150"/>

Once your MDBs are packaged, you will not need to change any of the files in the MDB jar - just provide the properties in the server configuration.

于 2015-02-13T19:33:49.597 回答
0

您可以避免在 MDB 中添加主机名、端口号等,您只需在 MDB 中定义destinationType,其余的您可以在应用服务器中配置,例如激活规范、队列和队列连接工厂。我做了同样的事情,但我使用了 IBM Websphere Application Server。

于 2013-10-14T07:17:49.743 回答