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 » javax.jms versus com.ibm.mq.jms

Post new topic  Reply to topic
 javax.jms versus com.ibm.mq.jms « View previous topic :: View next topic » 
Author Message
ProgrammerDude
PostPosted: Thu Dec 31, 2009 5:00 pm    Post subject: javax.jms versus com.ibm.mq.jms Reply with quote

Newbie

Joined: 31 Dec 2009
Posts: 2

Hello, I'm new to JMS (and this forum), but familiar with using Java and, what I believe y'all would call, MQI. Thanks to the resources of this site and some other helpful pages, I've got working JMS Java code...

Actually, I have two sets of JMS code, and therein lies my question. What is the functional difference (if any) between the javax.jms classes and the com.ibm.mq.jms classes? I've searched this site, and either my search skills suck, or no one has asked this question before (which seems odd to me...am I asking a really dumb question?).

Minus the support code, my choice seems between this:

Code:
MQQueueConnectionFactory  cf = new MQQueueConnectionFactory();
QueueConnection  conn = cf.createQueueConnection();
QueueSession  sess = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue  queue = new MQQueue("queue:///" + qName);
QueueReceiver receiver = sess.createReceiver(queue);

And this:

Code:
MQQueueConnectionFactory  cf = new MQQueueConnectionFactory();
MQQueueConnection  conn = (MQQueueConnection) cf.createQueueConnection();
MQQueueSession  sess = (MQQueueSession) conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
MQQueue  queue = new MQQueue("queue:///" + qName);
MQQueueReceiver receiver = (MQQueueReceiver) sess.createReceiver(queue);

The former seems simple and clean and appeals to my revulsion of casts. The latter appeals to my preference for specificity where appropriate (there is zero chance of changing away from MQ).

Six of one, 0.5 dozen of the other?
HAPPY NEW YEAR!!
Back to top
View user's profile Send private message
mvic
PostPosted: Thu Dec 31, 2009 5:25 pm    Post subject: Re: javax.jms versus com.ibm.mq.jms Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

ProgrammerDude wrote:
Code:
MQQueueConnectionFactory  cf = new MQQueueConnectionFactory();
QueueConnection  conn = cf.createQueueConnection();


Would this even work? QueueConnection is an interface. MQQueueConnection "implements" the QueueConnection interface, among others. My rather rusty OO memory tells me you can instantiate a class but not an interface.

Did you test that both code snippets you posted actually work?

Here's the link to the javadoc for MQQueueConnection in case it helps:

http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.javadoc.doc/WMQJMSClasses/com/ibm/mq/jms/MQQueueConnection.html
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Dec 31, 2009 6:21 pm    Post subject: Reply with quote

Grand High Poobah

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

To answer your first question:
javax.jms.* holds the interface classes and all that is needed to access the implementation for the necessary instantiations.

com.ibm.mq.jms.* and all the other jars contain the implementation of the JMS provider for WebSphere MQ.

So it is OK to program in JMS without ever using any of the MQ specific classes. Remember however that JMS will only work if you have all the provider classes on the classpath...

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
WMBDEV1
PostPosted: Sat Jan 02, 2010 6:40 am    Post subject: Re: javax.jms versus com.ibm.mq.jms Reply with quote

Sentinel

Joined: 05 Mar 2009
Posts: 888
Location: UK

mvic wrote:

Would this even work? QueueConnection is an interface. MQQueueConnection "implements" the QueueConnection interface, among others. My rather rusty OO memory tells me you can instantiate a class but not an interface.


The interface is not being instantiated here (just referenced). Using the interface in this way is ok (and is better than actually casting to the undelying class that implements the QueueConnection interface as it allows more felxibility in the future).
Back to top
View user's profile Send private message
ProgrammerDude
PostPosted: Mon Jan 04, 2010 8:53 am    Post subject: Reply with quote

Newbie

Joined: 31 Dec 2009
Posts: 2

@fjb_saper: Thanks, that explains it perfectly. (So perfectly that it's a head-slap moment... D'Oh! I shoulda been able to figure that out myself.)

@mvic: Yep, as @WMBDEV1 says, I'm just using the Interface class to be as abstract as possible. (As a future data point, I never post code that I haven't tried.... unless, of course, the problem is I can't get the code to work!

Thanks all!
Back to top
View user's profile Send private message
mvic
PostPosted: Mon Jan 04, 2010 9:04 am    Post subject: Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

ProgrammerDude wrote:
(As a future data point, I never post code that I haven't tried.... unless, of course, the problem is I can't get the code to work!

This is as it should be. But even so, IMHO you should say so explicitly just for the avoidance of doubt.

Anyway, I apologise for my Java mistake / lack of understanding.
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 » javax.jms versus com.ibm.mq.jms
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.