手机版
你好,游客 登录 注册
背景:
阅读新闻

如何在 JBoss 里配置 IBM MQ

[日期:2012-06-17] 来源:oschina  作者:迷途d书童 [字体:大 中 小]

在本文中,我将告诉大家如何在JBoss里安装、配置WebSphere MQ资源适配器。

安装WebSphere MQ资源适配器:   
从安装目录复制wmq.jmsra.rar文件到服务器的部署目录中,例如:<安装路径>/server/default/deploy。此时资源适配器将会自动选择服务器。

安装WebSphere MQ扩展事务客户端:   
WebSphere MQ扩展事务客户端允许你使用XA分布式事务,并用客户端模式连接到WebSphere MQ队列管理器。要将客户端安装在JBoss,需要从安装目录复制com.ibm.mqetclient.jar文件到服务器的lib目录中,例如<安装路径>/server/default/lib。

为你的应用程序配置资源适配器:   
WebSphere MQ资源适配器允许你定义一些全局的属性。在JBoss中JCA出站流的资源定义在-ds.xml文件,名为wmq.jmsra-ds.xml。

此文件的概要如下:

<?xml version="1.0" encoding="UTF-8"?>
<connection-factories>
  <!-- mbeans defining JCA administered objects -->
  <mbean/>
  <!-- JCA Connection factory definitions -->
  <tx-connection-factory/>
</connection-factories>

从上可以看出JCA连接工厂的定义在<tx-connection-factory>元素,而且JMS队列和主题被定义在JCA的管理对象mbean里面。

简单的两个队列-入站和出站的完整示例如下:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<connection-factories>
    <tx-connection-factory>
        <jndi-name>jms/MyAppConnectionFactory</jndi-name>
        <rar-name>wmq.jmsra.rar</rar-name>
        <use-java-context>true</use-java-context>
        <connection-definition>javax.jms.QueueConnectionFactory</connection-definition>
        <min-pool-size>8</min-pool-size>
        <max-pool-size>36</max-pool-size>
        <config-property type="java.lang.String" name="channel">${channel}</config-property>
        <config-property type="java.lang.String" name="hostName">${hostName}</config-property>
        <config-property type="java.lang.String" name="port">1414</config-property>
        <config-property type="java.lang.String" name="queueManager">${queueManager}</config-property>
        <config-property type="java.lang.String" name="transportType">CLIENT</config-property>
        <config-property type="java.lang.String" name="username">munish</config-property>
        <security-domain-and-application>JmsXARealm</security-domain-and-application>
        <xa-transaction/>
    </tx-connection-factory>
    <mbean name="imq.queue:name=MY.APP.INBOUND.QUEUE" code="org.jboss.resource.deployment.AdminObject" >
  <attribute name="JNDIName">jms/IncomingQueue</attribute>
  <depends optional-attribute-name="RARName">jboss.jca:name='wmq.jmsra.rar',service=RARDeployment</depends>
  <attribute name="Type">javax.jms.Queue</attribute>
  <attribute name="Properties">
   baseQueueManagerName=${queueManager}
   baseQueueName=MY.APP.INBOUND.QUEUE
    </attribute>
    </mbean>
    <mbean name="imq.queue:name=MY.APP.OUTBOUND.QUEUE" code="org.jboss.resource.deployment.AdminObject">
        <attribute name="JNDIName">jms/OutgoingQueue</attribute>
        <depends optional-attribute-name="RARName">jboss.jca:name='wmq.jmsra.rar',service=RARDeployment</depends>
        <attribute name="Type">javax.jms.Queue</attribute>
        <attribute name="Properties">
            baseQueueManagerName=${queueManager}
            baseQueueName=MY.APP.OUTBOUND.QUEUE
        </attribute>
    </mbean>
</connection-factories>

在JBoss启动脚本中占位符属性被定义为:
-Dchannel=MQTEST -DhostName=localhost -DqueueManager=TST_MGR

linux
相关资讯       Jboss 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款