Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MQ and Java

Status
Not open for further replies.

upoirier

Programmer
Mar 6, 2003
5
CL
Hi all:
I don't know what is necessary to connect a J2EE component with other application by MQ-Series. I was reading about MA88, but I don't understand when to use mq.jar or mqjms.jar. I was reading too that the mqseries classes for Java (mq or mqjms?) allow a program written in Java to connect to MQSeries as an MQSeries Client using tcp/ip, or directly to an MQSeries Server using JNI.

Somebody can explain and clarify this things to me? what I must make to program a thread safe con MQ?

I'm developing with J2EE (Tomcat in Windows 2000, the MQSeries Server is running in OVMS/ALPHA, and I need to connect to other apllication that run in other server Windows 2000.

Thanks in advance.
 
You got it almost there. But there are some differences out there.

First of all you need to figure out what you plan to use, would it be Java classes supplied as part of mqseries(com.ibm.mq.jar) or jms(mqjms.jar/jms.jar, not 100% sure). You can get your application to connect to mqseries using either.

As for connecting to MQ is concerned, you specify all that info in your app itself, which includes the qm name, the svrconn channel name that you wish to use including the ip and port the channel listener is listening on.

I am not sure how to make a program thread safe. But my understanding is that MQ has nothing to do with it. It is your app that needs to code appropriately. In a multi-threaded environment, MQ comes into picture only when you are trying to access QM Objects accross threads.

HOpe this helps.
Cheers
KK
 
You are right, but endeed when I use a servlet or JSP the code that use the mq classes are part of a method named service(), which run how a thread.

Do you know what is the difference between mq.jar and mqjms.jar?

Thanks in advance, Ulises.
 
com.ibm.mq.jar is Java library and support for MQ Java classes. Where as mqjms.jar is proprietary of Sun microsystems which developed JMS.

Both use different api calls to get around connecting to MQ.

You can write a Java servlet or a java app using either of them. I am not sure what you meant by "method named service()".

Cheers
KK
 
Hi,

If you develop application using JSP/Servlet and want to use MQSeries as 'data' transportation, The steps :
1. You must setup JNDI server, you can use fscontext.jar and jndi.jar that supplied with MA88 for File System JNDI
2. You must create Queue, using MQSeries Explorer
3. You must create MQ Queue COntext Factory (QCF), use JMSAdmin (MA88) and don't forget to edit your JMSAdmin.config to use File System JNDI.
4. create class that implement method onMessage() (This is JMS implementation ) and put your logic inside, of course you must use MQ rules to connecting to MQ Server, please find on MQ Using Java or look at the samples, and set MQ Listener in stop() state. And don't forget also define method putMessage(), to put your message to Queue.
5. Create MQ Servlet that load on startup. Use only method init() and start your MQ Listener from it. The servlet will become thread process and try to connect to MQ Server and established after it.
6. Your can create class that contain only variable data that shareable between your jsp/servlet and MQ Servlet, or you can use database, whatever ...

Sorry maybe you are not really clear what i mean, but you can get an idea how to implement MQ as JMS on your J2EE(Tomcat).

There is another, you can use MQ Internet Gateway. But sorry i never use this method.

reg,

Fajar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top