ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Java MQ API (not JMS) in WAS servlets

Post new topic  Reply to topic
 Java MQ API (not JMS) in WAS servlets « View previous topic :: View next topic » 
Author Message
ivanachukapawn
PostPosted: Fri Nov 24, 2006 6:01 am    Post subject: Java MQ API (not JMS) in WAS servlets Reply with quote

Knight

Joined: 27 Oct 2003
Posts: 561

For reasons involving the difficulties associated with obtaining (using JMS) messaging features available only in MQSeries, I want to use base Java MQ API in the WAS servlet. Will it work for me to code my servlet to set the MQEnvironment variables correctly for a client connection (QM Name, Host, Port, SVRCONN) and then try to instantiate a MQQueueManager object to obtain a connection (thereby avoiding the use of JMS) ?
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Nov 24, 2006 6:05 am    Post subject: Re: Java MQ API (not JMS) in WAS servlets Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

ivanachukapawn wrote:
For reasons involving the difficulties associated with obtaining (using JMS) messaging features available only in MQSeries, I want to use base Java MQ API in the WAS servlet. Will it work for me to code my servlet to set the MQEnvironment variables correctly for a client connection (QM Name, Host, Port, SVRCONN) and then try to instantiate a MQQueueManager object to obtain a connection (thereby avoiding the use of JMS) ?


It should do, but but what features do you mean? If it's the RFH2 header confusing a base MQ application, be aware that can be suppressed with TARGCLIENT.

Or do you mean actual message features?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
ivanachukapawn
PostPosted: Fri Nov 24, 2006 6:15 am    Post subject: Reply with quote

Knight

Joined: 27 Oct 2003
Posts: 561

No, its not RFH2 header confusion driving me to ask this question. I want to have the flexibility to use some MQSeries messaging features (like message groups) and I think there are other MQSeries features not easily accessible via JMS (they are not common denominator features).
If I design the servlet to obtain the client connection using Java MQ API might I have performance problems down the road with lack of connection persistence? If this performance problem exists (i.e. the servlet obtains a new connection every time it is used), is there a way for MQQueueManager object to be persisted across invocations of the servlet?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Nov 24, 2006 6:37 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

In a client connection your main problem assuming that you might be accessing different qmgrs will be thread safety. Be aware that the MQEnvironment class is a singleton.

I am not convinced with your argument. I do believe that you can achieve grouping and other stuff in JMS. Read up about the JMS properties in the using java manual. Some may not be pure JMS and usually have JMS_IBM_.... as a name. In a J2EE environment you are most probably still better off using JMS as it will have seamless support for thread safety, scalability and other stuff like transactional support and such...

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
ivanachukapawn
PostPosted: Fri Nov 24, 2006 6:57 am    Post subject: Reply with quote

Knight

Joined: 27 Oct 2003
Posts: 561

I developed a prototype for Java app MQ Grouping via JMS but could not get it to work. Perhaps I didn't go deeply enough into the documentation but in either case, it presented difficulties.
If I do end up trying to get the Java MQ API working in a servlet, will I have performance problems related to repetitive obtaining of the MQ connection each time the servlet is invoked, and if so, is there a way to deal with that?
Also, with respect to the thread safety problem (MQEnvironment being a singleton), would my Java MQ API implementation clash with JMS connection factories re: this singleton?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Nov 24, 2006 7:23 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Can't help you there. I don't mix JMS and base java...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
jefflowrey
PostPosted: Fri Nov 24, 2006 8:34 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

A Singleton Collection makes a nice basic connection pool.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
billybong
PostPosted: Fri Nov 24, 2006 11:47 am    Post subject: Reply with quote

Disciple

Joined: 22 Jul 2005
Posts: 150
Location: Stockholm, Sweden

The answer to the question really depends on how the servlet will be used. You can use an application scope object for the connection pooling as Jeff suggested, and it is a good way to start. Another way is to put the MQ connection in a session scoped object and reuse it through the user session if the user will do multiple mq operations. For each MQ operation first check the bean and make sure the queue manager is not null and is connected, then perform the operations. If not connected, reconnect etc.. You must handle the disconnect whenever a session ends though. You probably want a combination of both, i.e. the session gets the qmgr connection from the application scoped collection and stores it as a session scoped object.

If you are unsure of how many connections you will ultimately have, always use mq pooling by getting and returning tokens from MQ as is documented in the programming guides.
_________________
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Integration Developer V6.0
IBM Certified System Administrator - WebSphere MQ V6.0
IBM Certified Solution Developer - WebSphere DataPower


Last edited by billybong on Fri Nov 24, 2006 7:51 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
ivanachukapawn
PostPosted: Fri Nov 24, 2006 11:57 am    Post subject: Reply with quote

Knight

Joined: 27 Oct 2003
Posts: 561

Thanks Billy and Jeff. I'll look at the connection pooling and session scoped object as ways to do this using the Java MQI API.
FJB, I don't have any intentions of mixing base API with JMS. What I meant was that I built a prototype to test access to MQ Message Grouping via JMS and was not successful. Thats why I may try non-JMS approach in the servlet.

Thanks all, for the help.
Back to top
View user's profile Send private message
andrisak
PostPosted: Fri Nov 24, 2006 12:05 pm    Post subject: Reply with quote

Newbie

Joined: 20 Mar 2006
Posts: 3

It is possible to use grouping and JMS. To send a message belonging to a group do something like this:

msg.setStringProperty("JMSXGroupSeq", "1");
msg.setStringProperty("JMSXGroupID", "myGroupId");
msg.setStringProperty("JMS_IBM_Last_Msg_In_Group", "true");

Use the same properties on the receiving side to determine what to do with the message.
Back to top
View user's profile Send private message
billybong
PostPosted: Fri Nov 24, 2006 7:46 pm    Post subject: Reply with quote

Disciple

Joined: 22 Jul 2005
Posts: 150
Location: Stockholm, Sweden

andrisak wrote:
It is possible to use grouping and JMS. To send a message belonging to a group do something like this:

msg.setStringProperty("JMSXGroupSeq", "1");
msg.setStringProperty("JMSXGroupID", "myGroupId");
msg.setStringProperty("JMS_IBM_Last_Msg_In_Group", "true");

Use the same properties on the receiving side to determine what to do with the message.


This probably works, but take into consideration the portability you need. All properties with "IBM" included are extra properties only used by the IBM implementation of JMS and not the standard J2EE interfaces.
_________________
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Integration Developer V6.0
IBM Certified System Administrator - WebSphere MQ V6.0
IBM Certified Solution Developer - WebSphere DataPower
Back to top
View user's profile Send private message Visit poster's website
fjb_saper
PostPosted: Sat Nov 25, 2006 10:35 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Portability is not the problem here as the alternative is using MQ base API.
However with the JMS pooling and scalability are already solved...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
jefflowrey
PostPosted: Sat Nov 25, 2006 1:03 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

fjb_saper wrote:
However with the JMS pooling and scalability are already solved...


ASSUMING you're running JMS in a JEE/J2EE container.

All bets are off, otherwise.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
ivanachukapawn
PostPosted: Sat Nov 25, 2006 1:09 pm    Post subject: Reply with quote

Knight

Joined: 27 Oct 2003
Posts: 561

Thanks for all the comments gentlemen.

At this point, I am convinced that I ought to go with JMS in the WAS container thereby dealing with scalability, connection pooling, portability (not a requirement anyway), and performance. If I need the message grouping, it appears there is a way to obtain this through JMS.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Java MQ API (not JMS) in WAS servlets
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.