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 » Difference betwen MQ JMS API and using JMS API

Post new topic  Reply to topic
 Difference betwen MQ JMS API and using JMS API « View previous topic :: View next topic » 
Author Message
anilit99
PostPosted: Thu May 28, 2009 5:54 am    Post subject: Difference betwen MQ JMS API and using JMS API Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Thu May 28, 2009 7:02 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
anilit99
PostPosted: Fri May 29, 2009 12:38 am    Post subject: Reply with quote

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
View user's profile Send private message
anilit99
PostPosted: Fri May 29, 2009 12:45 am    Post subject: Reply with quote

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
View user's profile Send private message
JLRowe
PostPosted: Fri May 29, 2009 1:18 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
anilit99
PostPosted: Fri May 29, 2009 1:34 am    Post subject: Reply with quote

Voyager

Joined: 28 May 2009
Posts: 75
Location: London, UK

sweet !

thanks a ton, fjb_saper, JLRowe !

-Anil.
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 » Difference betwen MQ JMS API and using JMS API
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.