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 » How To Browser a Msg from A Q with Java Code?

Post new topic  Reply to topic
 How To Browser a Msg from A Q with Java Code? « View previous topic :: View next topic » 
Author Message
nyey
PostPosted: Wed Apr 02, 2003 8:29 am    Post subject: How To Browser a Msg from A Q with Java Code? Reply with quote

Acolyte

Joined: 13 Mar 2003
Posts: 57

Can some body post some java code to browser a queue for a msg?
Back to top
View user's profile Send private message
vennela
PostPosted: Wed Apr 02, 2003 8:58 am    Post subject: Reply with quote

Jedi Knight

Joined: 11 Aug 2002
Posts: 4055
Location: Hyderabad, India

Have you looked at the "repository". There are a couple of samples.
There is one "mqbrowse.java" sample. I think it does a BROWSE first and then a GET. That should help you getting started.

-------
Venny
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nyey
PostPosted: Wed Apr 02, 2003 9:19 am    Post subject: Reply with quote

Acolyte

Joined: 13 Mar 2003
Posts: 57

Where can I find the 'repository'?
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Apr 02, 2003 9:24 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

At the top of this window.
Back to top
View user's profile Send private message
nyey
PostPosted: Wed Apr 02, 2003 9:35 am    Post subject: Reply with quote

Acolyte

Joined: 13 Mar 2003
Posts: 57

Cannot open the tar file from my win 2k. Can you post the java code here? Thx
Back to top
View user's profile Send private message
meekings
PostPosted: Wed Apr 02, 2003 9:55 am    Post subject: Reply with quote

Voyager

Joined: 28 Jun 2001
Posts: 86
Location: UK, South West

Try http://www.capitalware.biz/sample_mqseries.html#javacode
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vennela
PostPosted: Wed Apr 02, 2003 10:07 am    Post subject: Reply with quote

Jedi Knight

Joined: 11 Aug 2002
Posts: 4055
Location: Hyderabad, India

That's the next best place to go.

Here is something very simple. I think you need to adapt it. It works with local binding.
Call it MQBrowse.java
Usage

java MQBrowse <qname> <qmgrname>
eg

java MQBrowse SYSTEM.DEFAULT.LOCAL.QUEUE QM1

Code:
import com.ibm.mq.*;
public class MQBrowse extends Object {

    /** Creates new MQBrowse */
    public MQBrowse() {
    }

    /**
     * @param args the command line arguments
     */
    public static void main (String args[]) {


        try {
            String QM1 = args[1];
            String QUEUE1 = args[0];
            MQQueueManager qmgr = new MQQueueManager(QM1 ) ;
            System.out.println("Connected to QMGR " + QM1);
            int openOptions = MQC.MQOO_BROWSE | MQC.MQOO_FAIL_IF_QUIESCING ;
            MQQueue BrowseQueue = qmgr.accessQueue(QUEUE1 , openOptions, null, null, null);
            MQGetMessageOptions gmo = new MQGetMessageOptions() ;
            gmo.options = MQC.MQGMO_BROWSE_NEXT + MQC.MQGMO_FAIL_IF_QUIESCING + MQC.MQGMO_CONVERT;

            MQMessage BrowseMsg = new MQMessage();

            BrowseQueue.get(BrowseMsg, gmo);

            int msgLength = BrowseMsg.getMessageLength() ;
            String msgTxt = BrowseMsg.readString(msgLength);
            System.out.println (" The message is \n" + msgTxt);
            BrowseQueue.close();
            qmgr.disconnect() ;

        }
        catch(MQException ex){
            System.out.println("MQ Error - Reason code :" + ex.reasonCode);
        }
        catch (Exception e){
            System.out.println("Error : " + e);
        }
    }

}


-------
Venny
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nyey
PostPosted: Wed Apr 02, 2003 11:21 am    Post subject: Reply with quote

Acolyte

Joined: 13 Mar 2003
Posts: 57

Thanks Venny....
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 » How To Browser a Msg from A Q with Java Code?
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.