Author |
Message
|
nyey |
Posted: Wed Apr 02, 2003 8:29 am Post subject: How To Browser a Msg from A Q with Java Code? |
|
|
Acolyte
Joined: 13 Mar 2003 Posts: 57
|
Can some body post some java code to browser a queue for a msg? |
|
Back to top |
|
 |
vennela |
Posted: Wed Apr 02, 2003 8:58 am Post subject: |
|
|
 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 |
|
 |
nyey |
Posted: Wed Apr 02, 2003 9:19 am Post subject: |
|
|
Acolyte
Joined: 13 Mar 2003 Posts: 57
|
Where can I find the 'repository'? |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Apr 02, 2003 9:24 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
At the top of this window. |
|
Back to top |
|
 |
nyey |
Posted: Wed Apr 02, 2003 9:35 am Post subject: |
|
|
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 |
|
 |
meekings |
Posted: Wed Apr 02, 2003 9:55 am Post subject: |
|
|
 Voyager
Joined: 28 Jun 2001 Posts: 86 Location: UK, South West
|
|
Back to top |
|
 |
vennela |
Posted: Wed Apr 02, 2003 10:07 am Post subject: |
|
|
 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 |
|
 |
nyey |
Posted: Wed Apr 02, 2003 11:21 am Post subject: |
|
|
Acolyte
Joined: 13 Mar 2003 Posts: 57
|
|
Back to top |
|
 |
|