weblogic和mq的集成
weblogic:8.1 sp2MQ:5.3
摘要:把weblogic 和MQ集成起來是非常有價值的應用。本文討論使用weblogic的Foreign JMS Server 配置JNDI,MDB配置,使用MQ提供的
JMSADMIN配置MQ的jndi。也沒有那么詳細啦,還是需要讀者自己作一番小小的努力的。
關鍵詞:jms,Weblogic foreign JMS Server,JNDI,JMSAdmin
開始:
1、安裝Weblogic 和MQ(廢話)。
2、配置JMSAdmin(就是在 mq安裝目錄下的 java/bin/目錄里沒有擴展名的的文件)
uncomment下面兩行,同時在你的機器上建相應的目錄C:/JNDI-Directory
java代碼: |
INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory PROVIDER_URL=file:/C:/JNDI-Directory |
以上配置適用于使用文件jndi。
3、配置mq的jndi
下面使用jmsadmin配置mq的jndi。
下面是使用jmsadmin的一些命令的例子。
其實你可以去ibm的網站上面下載圖形界面的東東,就不用記這些命令啦。
這個東東叫:JMSADMINGUI
java代碼: |
def qcf(ivtQCF) def q(ivtQ) qu(SYSTEM.DEFAULT.LOCAL.QUEUE) def tcf(ivtTCF) def t(ivtT) topic(MQJMS/PSIVT/Information) |
或者你可以執行IVTSETUP腳本來完成一個可以使用的JNDI配置。
4、配置Weblogic的Foreign JMSServer以下屬性進行配置:
java代碼: |
JNDI Initial Context Factory->com.sun.jndi.fscontext.RefFSContextFactory JNDI Connection URL->file:/C:/JNDI-Directory |
5、配置Foreign JMS Connection Factories
代碼:
java代碼: |
Local JNDI Name:mqqcf(在weblogic 中使用的QueueConnectionFactory的JNDI的名字) Remote JNDI Name:ivtQCF(已經在通過jmsadmin配置o玫?jndi的名字) |
6、配置foreign JMS destination
java代碼: |
Local JNDI Name: MQQUEUE Remote JNDI Name: ivtQ |
同上。
7、MDB配置
java代碼: |
<?xml version="1.0"?> <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd"> <!-- This ejb-jar.xml file defines a message-driven bean called "SimpleMDB". It uses container-managed transactions, because "transaction-type" is "Container" and "trans-attribute" is "Required". --> <ejb-jar> <enterprise-beans> <message-driven> <ejb-name>ReceiveMessageMDB</ejb-name> <ejb-class>com.rm.mdb.ReceiveMessageBean</ejb-class> <transaction-type>Container</transaction-type> <message-driven-destination> <!-- In WebLogic Server 6.0, this next parameter is named "jms-destination-type" --> <destination-type>javax.jms.Queue</destination-type> </message-driven-destination> </message-driven> </enterprise-beans> <assembly-descriptor> <container-transaction> <method> <ejb-name>ReceiveMessageMDB</ejb-name> <method-name>*</method-name> </method> <trans-attribute>NotSupported</trans-attribute> </container-transaction> </assembly-descriptor> </ejb-jar> |
java代碼: |
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE weblogic-ejb-jar PUBLIC '-//BEA Systems, Inc.//DTD WebLogic 8.1.0 EJB//EN' 'http://www.bea.com/servers/wls810/dtd/weblogic-ejb-jar.dtd'> <weblogic-ejb-jar> <weblogic-enterprise-bean> <ejb-name>ReceiveMessageMDB</ejb-name> <message-driven-descriptor> <pool> <max-beans-in-free-pool>8</max-beans-in-free-pool> <initial-beans-in-free-pool>1</initial-beans-in-free-pool> </pool> <destination-jndi-name>MQQUEUE</destination-jndi-name> <initial-context-factory> weblogic.jndi.WLInitialContextFactory </initial-context-factory> <provider-url>t3://localhost:7001</provider-url> <connection-factory-jndi-name>MQQCF</connection-factory-jndi-name> </message-driven-descriptor> </weblogic-enterprise-bean> </weblogic-ejb-jar> |
注意:
如果 ejb-jar.xml中的<trans-attribute>NotSupported</trans-attribute>
為required則需要使用XAQueueConnectionFactory.
posted on 2006-03-07 11:51 輕松 閱讀(3390) 評論(1) 編輯 收藏 所屬分類: JAVA轉貼