Author |
Message
|
anilit99 |
Posted: Thu May 28, 2009 5:54 am Post subject: Difference betwen MQ JMS API and using JMS API |
|
|
 Voyager
Joined: 28 May 2009 Posts: 75 Location: London, UK
|
Hi there,
I am a bit confused here. I understand there are two ways to post messages in a MQ queue.
1. Bind the Administered objects (using JCA), look up the connection factory (JMS), look up the queue and post the message.
2. Use the MQQueueConnectionFactory provided by MQ and post the messages.
I mean, I dont see why we have to use the first method at all. Is there any special scenario where we can use this JCA administered objects ? because the second method looks very easy and no bindings are necessary !
p.s : I am not sure I am in the right forum, if not can somebody point me to the right direction ?
thanks
Anil. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu May 28, 2009 7:02 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You are in the right forum.
As to your question:
Your mode 2 is all based on proprietary code ... at least in part (set up of the connection factory) and as such is not portable (from one provider to the other)...
This is why the proprietary part is usually limited to the JNDI setup.
What happens afterwards is then as J2EE JMS like as possible and supports a change of JMS provider without changing the code.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
anilit99 |
Posted: Fri May 29, 2009 12:38 am Post subject: |
|
|
 Voyager
Joined: 28 May 2009 Posts: 75 Location: London, UK
|
I am trying to understand your statements here.
Quote: |
This is why the proprietary part is usually limited to the JNDI setup. |
this is part of my code which uses the proprietary code
Code: |
MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
// Config
cf.setHostName("hostname");
cf.setPort(1414);
cf.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
cf.setQueueManager("QM_hostname");
cf.setChannel("SYSTEM.DEF.SVRCONN");
MQQueueConnection connection = (MQQueueConnection) cf.createQueueConnection();
MQQueueSession session = (MQQueueSession) connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
MQQueue queue = (MQQueue) session.createQueue("queue:///testqueue");
MQQueueSender sender = (MQQueueSender) session.createSender(queue); |
and after this, I straight away start the connection and send messages. I dont see JNDI setup code here. I am still confused here.
I am able to send and receive messages this way.
As far as portability is concerned, i am not too much worried about that. So, are there any other issues by using this code to lookup and create messages ?
many thanks
Anil. |
|
Back to top |
|
 |
anilit99 |
Posted: Fri May 29, 2009 12:45 am Post subject: |
|
|
 Voyager
Joined: 28 May 2009 Posts: 75 Location: London, UK
|
NOT RELATED :
the sample code link at the top is broken. Its displaying an error page.
thanks
Anil. |
|
Back to top |
|
 |
JLRowe |
Posted: Fri May 29, 2009 1:18 am Post subject: |
|
|
 Yatiri
Joined: 25 May 2002 Posts: 664 Location: South East London
|
anilit99, don't worry about the JNDI comment as you are not using JNDI.
If you are not worried about portability then leave the code as is. But, in the last 4 lines of your code you could cast to the JMS non-specific interfaces and so limit JMS provider specific code to the connection factory setup. i.e. cast to Queue instead of MQQueue.
This is generally considered good practice. |
|
Back to top |
|
 |
anilit99 |
Posted: Fri May 29, 2009 1:34 am Post subject: |
|
|
 Voyager
Joined: 28 May 2009 Posts: 75 Location: London, UK
|
sweet !
thanks a ton, fjb_saper, JLRowe !
-Anil. |
|
Back to top |
|
 |
|