|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
javax.jms versus com.ibm.mq.jms |
« View previous topic :: View next topic » |
Author |
Message
|
ProgrammerDude |
Posted: Thu Dec 31, 2009 5:00 pm Post subject: javax.jms versus com.ibm.mq.jms |
|
|
 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 |
|
 |
mvic |
Posted: Thu Dec 31, 2009 5:25 pm Post subject: Re: javax.jms versus com.ibm.mq.jms |
|
|
 Jedi
Joined: 09 Mar 2004 Posts: 2080
|
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Dec 31, 2009 6:21 pm Post subject: |
|
|
 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 |
|
 |
WMBDEV1 |
Posted: Sat Jan 02, 2010 6:40 am Post subject: Re: javax.jms versus com.ibm.mq.jms |
|
|
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 |
|
 |
ProgrammerDude |
Posted: Mon Jan 04, 2010 8:53 am Post subject: |
|
|
 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 |
|
 |
mvic |
Posted: Mon Jan 04, 2010 9:04 am Post subject: |
|
|
 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 |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|