Integrate MQ and WebSphere
Reference article: http://www2.tw.ibm.com/developerWorks/Tutorial/content/20021207.html
surroundings:
Win2000 SP4 WebSphere4 AES MQ5.2.1
This article assumes that WebSphere and MQ5.2.1 have been properly installed and define the following queue manager on MQ, switch to C: / Program files / IBM / MQSeries / BIN under DOS, type:
Crtmqm -q qm_test
Strmqm qm_test
Runmqsc qm_test
Define QL (deadQ_test) Defpsist (YES) Replace
Alter QMgr deadq (deadQ_test)
Define Process (p_test) AppLTYPE (WindowsNT) Applicid ('Runmqchl -c SDR_TEST -M QM_TEST') Replace
Define QL (qt_test) Usage (xmitq) Defpsist (yes) initq (system.channel.initq) process (p_test) Replace
Define QRemote (qr_test) RQMNAME (QM_TEST1) XMITQ (Qt_Test) Replace
Define Channel (SDR_TEST) CHLTYPE (SDR) Conname ('192.168.0.28 (2001)) XMITQ (Qt_Test) Replace
Define Channel (SDR_TEST1) CHLTYPE (RCVR) Replace
Define Channel (s_test) CHLTYPE (SVRCONN) Replace
Runmqlsr -t tcp -p 2001 -m qm_test
START CHL (SDR_TEST)
(The above statement is best typed manually, because some statements are divided into two lines. - :)
The download address of the required running environment:
Point-to-point mode (MA_88):
Http://www-3.ibm.com/software/integration/support/supportpacs/individual/ma88.html
Publish / Subscription Mode (MA_0C): http://www-3.ibm.com/software/integration/support/supportpacs/individual/ma0c.html
Download the above package and install it. The specific system takes a point-to-point or publish / subscribe mode to select the installation. Or both are installed. Remember to restart now and do not press the default path to install the package to C: / Program Files. Because this will cause the ClassPath length to be more than 255, the error will not be found when the class will be reported at runtime.
Convention:
In this article% MQ_JAVA_INSTALL_PATH% = C: / MQSeries;
% WAS_HOME% = E: / WebSphere / appserver;
1.
Modify the jmsadmin.config of% mq_java_install_path% / bin,
Initial_Context_Factory = com.sun.jndi.fscontext.reffsContextFactory front plus #
Let's take another one: initial_context_factory = com.ibm.ejs.ns.jndi.cninitialcontextFactory
In Provider_url = ldap: // Polaris / O = IBM_US, C = USA front plus # below: provider_url = iiop: // localhost /
2.
Modify JMSADMIN.BAT:
@echo on
Rem -------------------------------------------------------------------------------
REM IBM MQSeries JMS Admin Tool Execution Script
REM
Rem Note That The Properties Passed to the Java
Rem Program Are Defaults, And Should Be Edited
Rem to suit your installation if Necessary
Rem -------------------------------------------------------------------------------
Java -dmqjms_log_dir = C: / MQSeries / LOG
-Dmqjms_trace_dir = C: / MQSeries / Trace
-Dmqjms_install_path = C: / MQSeries
-Dserver.root = E: / WebSphere / appserver com.ibm.mq.jms.admin.jmsAdmin% 1% 2% 3% 4% 5
PAUSE
3.
Add a text file:
@echo on
@rem java runtime
Set java_home =% was_home% / java / bin
@Rem MQ JMS
Set mq =% MQ%;% mq_java_install_path% / lib
Set MQ =% MQ%;% mq_java_install_path% / lib / com.ibm.mq.jar
Set mq =% MQ%;% mq_java_install_path% / lib / com.ibm.mqjms.jar
Set mq =% MQ%;% mq_java_install_path% / lib / jms.jar
Set mq =% MQ%;% mq_java_install_path% / lib / com.ibm.mq.iiop.jar
Set mq =% MQ%;% mq_java_install_path% / lib / com.ibm.mqbind.jar
SET MQ =% MQ%;% mq_java_install_path% / lib / jndi.jar
Set mq =% MQ%; E: /WEBSPHERE/AppServer/java/jre/lib/rt.jar
@Rem Needed IF Using LDAP OR File System for JNDI
SET MQ =% MQ%;% mq_java_install_path% / lib / ldap.jar
@Rem Needed IF Using The File System for JNDI
Set mq =% MQ%;% mq_java_install_path% / lib / fscontext.jar
Set mq =% MQ%;% mq_java_install_path% / lib / providerutil.jar
@Rem Needed to Use WebSphere Name Service for JNDI
SET WebSpherecp =% WAS_HOME% / lib / ns.jar
Set classpath =% MQ%;% WebSphereCp%;% classpath%
SET PATH =% java_home%;% mq_java_install_path% / lib;% PATH%;
Save this text file as STenv.bat, save it to% mq_java_install_path% / bin. The above command is all the .jar files and% WAS_HOME% / java / jre / lib / RT.jar in% mq_java_install_path% / lib / r.jar, and the java_home variable % WAS_HOME% / java / bin.
Run CMD, switch to% mq_java_install_path% / bin, run Setenv. Check that the path is correct.
Run JMSADMIN -T -V -CFG JMSADMIN.CONFIG
If you see the above prompt, configure it correctly, otherwise follow the prompt information. Most are not found, please modify Stenv.bat itself.
4.
Define QueueConnectionFactory -> QCF:
Type:
Define QCF (TEST) qManager (QM_TEST)
Definition queue
Type: Define Q (TEST1) Queue (Q_Test) qmanager (QM_TEST)
Type: end
5.
Add the path to% MQ_JAVA_INSTALL_PATH% / lib in the Path system variable of Windows 2000
Run start -> Program -> IBM WebSphere-> Application Server V4.0AES-> Start Application Server.
Type http: // localhost: 9090 / admin / in the user ID, in the user ID, such as Test. Click on the node of the tree on the left -> Your Node Name -> Application Server -> Default Server-> Process Definition -> JVM Settings
Add:% MQ_JAVA_INSTALL_PATH% / lib;% mq_java_install_path% / lib / com.ibm.mq.jar;% mq_java_install_path% / lib / com.ibm.mqjms.jar;% WAS_HOME% / lib / j2ee.jar
Click "OK" to restart the Default Server.
6.
Type http: // localhost: 9090 / admin / in the IE address bar, type TEST in the user ID,
Enter% MQ_JAVA_INSTALL_PATH% / lib;% mq_java_install_path% / lib / com.ibm.mq.jar;
% MQ_JAVA_INSTALL_PATH% / lib / com.ibm.mqjms.jar;% mq_java_install_path% / lib / fscontext.jar;
% MQ_JAVA_INSTALL_PATH% / LIB / ProviderUtil.jar
Enter in the external initial context factory: com.ibm.ejs.ns.jndi.cninitialcontextFactory Click "OK"
Point JMS Supplier -> IBM MQSeries (Local WebSphere Naming Context) -> JMS Connection Factory, fill in TEST in the name, fill in TEST in the external JNDI name, select the queue in the connection type, click "OK".
Point JMS Supplier -> IBM MQSPhere Naming Context -> JMS Target, fill in Test1 in the name and external JNDI name, select the queue in the target type. Click "OK".
Write a test program:
Import javax.naming. *; import com.ibm.jms. *;
Import com.ibm.mq.jms. *;
Import javax.jms. *;
Import com.ibm.rmi.iop. *;
Import java.util. *;
Import com.ibm.ejs.ns.jndi. *;
Public class testConnection {
Public TestConnection () {
}
Public static void main (String [] args) {
TestConnection TestConnection1 = New TestConnection ();
Try {
Properties PROPS = New Properties ();
Props.Put (Context.Initial_Context_Factory, "com.ibm.ejs.ns.jndi.cninitialcontextfactory);
Props.Put (Context.Provider_URL, "IIOP: // LocalHost /");
Props.Put (Context.Security_Authentication, "NONE");
InitialContext CTX = New InitialContext (PROPS);
QueueConnectionFactory QCF = (QueueConnectionFactory) CTX.lookup ("test");
QueueConnection QC = Qcf.createqueueConnection ();
Queuesession session = qc.createqueness (false, session.auto_acknowledge);
Queue Q = (Queue) CTX.lookup ("Test1");
Queuesender Sender = session.createsender (q);
TextMessageTM = session.createtextMessage ();
TM.SETTEXT ("Hahaha!");
Sender.send (TM);
} catch (javax.naming.namingexception ne) {
Ne.PrintStackTrace ();
} catch (javax.jms.jmsexception jmse) {
JMse.PrintStackTrace ();
}
}
}
At this point, the setting of the point is ended. As for the release / subscription mode, it will be sent later.
If you have a place, please advise.