配置MDB以在JBoss EAP6.1中连接到IBM MQ

时间:2015-11-10 13:38:21

标签: jboss7.x ibm-mq

我正在尝试配置WAR中捆绑的MDB以连接到IBM MQ。

我正在使用@ActivationConfigProperty并尝试将值定义为系统属性。但这不起作用。

在查看文档之后,我发现我必须在standalong-full.xml中定义如下所示。但是,当我向JBoss添加应用程序属性时,这对我没有任何意义。如果我重新安装JBoss,我还要记得添加这些东西。

<resource-adapter>
<archive>
wm q.jm sra-VERSION.rar
</archive>
<transaction-support>NoTransaction</transaction-support>
<connection-definitions>
<connection-definition classname="com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl" jndi-name="java:jboss/MQ.CONNECTIONFACTORY.NAME"
pool-nam e="MQ.CONNECTIONFACTORY

任何人都可以建议任何替代方法。

提前致谢并感谢您的帮助。

最诚挚的问候 - 罗伊

2 个答案:

答案 0 :(得分:0)

罗伊, 您不需要直接修改standalone-full.xml。这个文件被JBoss覆盖了。首选方法是通过命令行界面cli进行这些更新。您通过cli进行的任何更改都将写入standalone-full.xml。进入cli后,您可以发出

之类的命令
/subsystem=resource-adapters/resource-adapter=mymq:add(archive="wm q.jm sra-VERSION.rar",transaction-support="NoTransaction")
/subsystem=resource-adapters/resource-adapter=mymq/connection-definitions="TopicConnection":add(class-name="com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl",jndi-name="java:jboss/MQ.CONNECTIONFACTORY.NAME",enabled="true",use-java-context="true",use-ccm="true",min-pool-size=1,max-pool-size=20)
顺便说一句,为什么你的档案名称中有空格&#34; wm q.jm&#34;,这可能不是问题,只是好奇。

答案 1 :(得分:0)

您需要将IBM MQ JCA部署到JBoss。这可以通过Web界面或CLI完成。这将导致您的独立配置文件中的条目类似于:

    <deployments>
    <deployment name="wmq.jmsra-7.5.0.5.rar" runtime-name="wmq.jmsra-7.5.0.5.rar">
        <content sha1="b6f5a197dcda61c38215ffc24666d2d028341323"/>
    </deployment>

然后,您需要创建匹配的资源适配器配置部分:

        <subsystem xmlns="urn:jboss:domain:resource-adapters:1.1">
        <resource-adapters>
            <resource-adapter id="wmq.jmsra-7.5.0.5.rar">
                <archive>
                    wmq.jmsra-7.5.0.5.rar
                </archive>
                <transaction-support>XATransaction</transaction-support>
                <config-property name="maxConnections">
                    100
                </config-property>
                <config-property name="reconnectionRetryCount">
                    1000
                </config-property>
                <config-property name="reconnectionRetryInterval">
                    30000
                </config-property>
            </resource-adapter>
        </resource-adapters>
    </subsystem>

请注意,名称wmq.jmsra-7.5.0.5.rar一致使用。

在您的MDB中,您将拥有:

@MessageDriven(name = "WebSphereMQ", activationConfig = {
    @ActivationConfigProperty(propertyName = "maxPoolDepth", propertyValue="100"),
    @ActivationConfigProperty(propertyName = "maxMessages", propertyValue="1"),
    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
    @ActivationConfigProperty(propertyName = "hostName", propertyValue = "10.0.0.150"),
    @ActivationConfigProperty(propertyName = "port", propertyValue = "1414"),
    @ActivationConfigProperty(propertyName = "channel", propertyValue = "SYSTEM.DEF.SVRCONN"),
    @ActivationConfigProperty(propertyName = "queueManager", propertyValue = "QUEUE.MANAGER"),
    @ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "false"),
    @ActivationConfigProperty(propertyName = "destination", propertyValue = "${the.queue.name}"),
    @ActivationConfigProperty(propertyName = "transportType", propertyValue = "CLIENT") })

@ResourceAdapter(value="wmq.jmsra-7.5.0.5.rar")
public class WebSphereMQ implements MessageListener {
...
...
...
}

请注意@ResourceAdapter${the.queue.name}

必须在独立配置文件中启用注释的属性替换:

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