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 » Sending message from a JAVA application to a clustered queue

Post new topic  Reply to topic
 Sending message from a JAVA application to a clustered queue « View previous topic :: View next topic » 
Author Message
AndyJB444
PostPosted: Tue Nov 15, 2005 2:09 pm    Post subject: Sending message from a JAVA application to a clustered queue Reply with quote

Newbie

Joined: 03 Nov 2005
Posts: 4
Location: Washington D.C.

Hi,

I have written a Java App that connects to a MQ queue and puts a message on said queue. My question is: will my current set up/code work when putting messages on a clustered queue since there is no local queue explicity defined for that queue manager. Will the app still be able to connect to the clustered queue through that local clustered queue manager? It currently works with a local QM and local Q. Thanks for your explanation. Attached is the code for making my connection:

Code:

protected void enqueue(String contents, String fileName) {

       
        String messageContents = contents;

       
        String HOSTNAME =  "localhost";
        String QMGRNAME = "TEST_CONFIRM_QM";
        String CHANNEL =  "SYSTEM.DEF.SVRCONN";
        String QUEUE = "TEST.MPTD.PUBLISH.CMI";
        int PORT = 1415;
      

        try{
           
           com.ibm.mq.jms.MQQueueConnectionFactory factory;
           factory = new com.ibm.mq.jms.MQQueueConnectionFactory();
           factory.setTransportType( com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP );
           factory.setQueueManager(QMGRNAME);
           factory.setHostName(HOSTNAME);
           factory.setChannel(CHANNEL);
           factory.setPort(PORT);
       
     
           QueueConnection connection = factory.createQueueConnection(  );
            QueueSession session =
                connection.createQueueSession( true, Session.AUTO_ACKNOWLEDGE );
            Queue queue = session.createQueue(QUEUE);
            QueueSender sender = session.createSender( queue );
           
            TextMessage msg = session.createTextMessage();
           
            msg.setText(messageContents);                                                       
           
          try {
             msg.setStringProperty(MSG_PARAM_NAME_IP_ADDR,
                getLocalHostIPAddr());
             msg.setStringProperty(MSG_PARAM_NAME_HOST_NAME,
                   getLocalHostName());
             msg.setStringProperty(MSG_PARAM_NAME_FILE_NAME,
                   fileName);
          } catch (JMSException jmse) {
             //throw new JmsRuntimeException(
                //   "JMS error: could message property.", jmse);
          }
          
            sender.send( msg );

            sender.close(  );
            session.commit(  );
            session.close(  );
            connection.close(  );
        }
        catch (Exception e)
      {
           System.out.println("In Exception: " + e.getMessage());

      }

        System.out.println( "Ending" );
    }
Back to top
View user's profile Send private message AIM Address
bower5932
PostPosted: Tue Nov 15, 2005 2:52 pm    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

You shouldn't have any problems putting to a queue that is in the cluster and not on your machine. Your program will connect to the local queue manager and WMQ will find the queue out in the cluster. Just remember, you can put to a queue in the cluster, but you can only get if the queue is actually defined on the queue manager where you are connected.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
ashoon
PostPosted: Tue Nov 15, 2005 3:12 pm    Post subject: for clustered queues Reply with quote

Master

Joined: 26 Oct 2004
Posts: 235

b/c the clustered queue instances do not belong to the 'local' queue manager you'd need to use the URI definition of a queue...

ioQueue = session.createQueue("queue:///SYSTEM.DEFAULT.LOCAL.QUEUE");


pg. 358 of the MQ V6 Java docs...

Note: When sending a message to a cluster, leave the queue manager field in the Queue object blank. This enables an MQOPEN call to be performed in
BIND_NOT_FIXED mode, which allows the queue manager to be
determined. Otherwise an exception is returned reporting that the Queue
object cannot be found. This applies when using JNDI or defining a queue
at runtime.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Nov 15, 2005 4:46 pm    Post subject: Reply with quote

Grand High Poobah

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

I believe you might have to use a cluster name qmgr alias to resolve to a blank qmgr name.

JMS by default will assume the current qmgr for queue:///qname

Enjoy
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Sending message from a JAVA application to a clustered queue
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.