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 » Reason 2046..., browse and lock, does it really work?

Post new topic  Reply to topic
 Reason 2046..., browse and lock, does it really work? « View previous topic :: View next topic » 
Author Message
Hannibal
PostPosted: Thu May 23, 2002 7:06 am    Post subject: Reason 2046..., browse and lock, does it really work? Reply with quote

Newbie

Joined: 23 May 2002
Posts: 4

I always get 2046 back when I specify
MQC.MQGMO_BROWSE_FIRST + MQC.MQGMO_LOCK
or
MQC.MQGMO_BROWSE_NEXT + MQC.MQGMO_LOCK
as get option.
It should work, following manual.
Have you ever try this?
Back to top
View user's profile Send private message
mqonnet
PostPosted: Thu May 23, 2002 7:14 am    Post subject: Reply with quote

Grand Master

Joined: 18 Feb 2002
Posts: 1114
Location: Boston, Ma, Usa.

Check to see if you are accidently specifying MQGMO_SYNCPOINT.
Post all your Gmo options here.

Cheers.
Kumar
_________________
IBM Certified WebSphere MQ V5.3 Developer
IBM Certified WebSphere MQ V5.3 Solution Designer
IBM Certified WebSphere MQ V5.3 System Administrator
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Hannibal
PostPosted: Thu May 23, 2002 7:33 am    Post subject: Reply with quote

Newbie

Joined: 23 May 2002
Posts: 4

Thanks for your reply.
These are the only get options I use. The queue is opened with
int openOptions = MQC.MQOO_INQUIRE + MQC.MQOO_BROWSE;
the get option
browseOptions.options = MQC.MQGMO_BROWSE_FIRST + MQC.MQGMO_LOCK;
and I call just
queue.get(message, browseOptions);

very simple.
The platform is Compaq Himalaya, anyway.
Back to top
View user's profile Send private message
mqonnet
PostPosted: Thu May 23, 2002 8:30 am    Post subject: Reply with quote

Grand Master

Joined: 18 Feb 2002
Posts: 1114
Location: Boston, Ma, Usa.

Sure works for me.

What version of Mq are you running. And if i understand it right, you are referring to NSK/TAndem.

Cheers.
Kumar
_________________
IBM Certified WebSphere MQ V5.3 Developer
IBM Certified WebSphere MQ V5.3 Solution Designer
IBM Certified WebSphere MQ V5.3 System Administrator
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Hannibal
PostPosted: Fri May 24, 2002 3:08 am    Post subject: Reply with quote

Newbie

Joined: 23 May 2002
Posts: 4

Version 5.1
And the OS is Tandem NSK, as you said.
It seems that MQGMO_LOCK is not supported for this platform (although it is not noted in the manual) since this option causes failure in sample C programs, too.
I'm going to implement the read method another way (not so nice and simple) but it will work.
Back to top
View user's profile Send private message
mqonnet
PostPosted: Fri May 24, 2002 4:28 am    Post subject: Reply with quote

Grand Master

Joined: 18 Feb 2002
Posts: 1114
Location: Boston, Ma, Usa.

It sure is supported and as i mentioned earlier, we have been using it for so long on V5.1. But yes, on V2201 it is not supported. And i have once again run the sample app with the scenario you just suggested and it works fine for me.

Is it possible for you to paste the pice of code or send me the source so that i shall try it out on our system.

Cheers.
Kumar
_________________
IBM Certified WebSphere MQ V5.3 Developer
IBM Certified WebSphere MQ V5.3 Solution Designer
IBM Certified WebSphere MQ V5.3 System Administrator
Back to top
View user's profile Send private message Send e-mail Visit poster's website
AndyMac
PostPosted: Wed May 29, 2002 6:52 am    Post subject: Reply with quote

Newbie

Joined: 29 May 2002
Posts: 1
Location: Glasgow, Scotland

mqonnet wrote:
It sure is supported and as i mentioned earlier, we have been using it for so long on V5.1. But yes, on V2201 it is not supported. And i have once again run the sample app with the scenario you just suggested and it works fine for me.

Is it possible for you to paste the pice of code or send me the source so that i shall try it out on our system.

Cheers.
Kumar
Quote:


Hi Kumar,

I too have experienced 2046 with this combination of get options. I was running MQ version 5.1 on Tandem/NSK release G06.12, and I tried modifying the sample C program AMQSBCG to include the LOCK option following an attempt by a developer to setup Java code in a similar fashion. Anything you can come up with would be gratefully received.

Cheers

Andy
Back to top
View user's profile Send private message
mqonnet
PostPosted: Wed May 29, 2002 8:31 am    Post subject: Reply with quote

Grand Master

Joined: 18 Feb 2002
Posts: 1114
Location: Boston, Ma, Usa.

Not sure why you are getting this error. Because it always works for me. I tried it again just for sanity purposes and worked just fine.

I too just modified these lines from the standard amqsbcg sample.

O_options = MQOO_INPUT_AS_Q_DEF /* open queue for input */
+ MQOO_BROWSE; /* but not if MQM stopping */

gmo.Options = MQGMO_BROWSE_FIRST + MQGMO_LOCK;

Let me know how it goes. If still getting problems. Send me accross your source with changes and i shall try your program.

Cheers.
Kumar
_________________
IBM Certified WebSphere MQ V5.3 Developer
IBM Certified WebSphere MQ V5.3 Solution Designer
IBM Certified WebSphere MQ V5.3 System Administrator
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Hannibal
PostPosted: Sun Jun 02, 2002 11:56 pm    Post subject: Reply with quote

Newbie

Joined: 23 May 2002
Posts: 4

Hi,
I have taken the original code from IBM and added the LOCK option
(see this comment // <-- lock option added)
I get always 2046.


/***************************************************************************/
/* */
/* (c) Copyright IBM Corp. 2000 All rights reserved. */
/* */
/* This sample program is owned by International Business Machines */
/* Corporation or one of its subsidiaries ("IBM") and is copyrighted */
/* and licensed, not sold. */
/* */
/* You may copy, modify, and distribute this sample program in any */
/* form without payment to IBM, for any purpose including developing, */
/* using, marketing or distributing programs that include or are */
/* derivative works of the sample program. */
/* */
/* The sample program is provided to you on an "AS IS" basis, without */
/* warranty of any kind. IBM HEREBY EXPRESSLY DISCLAIMS ALL WARRANTIES, */
/* EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
/* Some jurisdictions do not allow for the exclusion or limitation of */
/* implied warranties, so the above limitations or exclusions may not */
/* apply to you. IBM shall not be liable for any damages you suffer as */
/* a result of using, modifying or distributing the sample program or */
/* its derivatives. */
/* */
/***************************************************************************/
/* */
/* Program name: mqbrowse */
/* */
/* Description: Sample java program that shows MQSeries browsing/getting */
/* of messages on a queue */
/* */
/***************************************************************************/
/* */
/* Function: */
/* */
/* This program is a java program that shows the use of a browse message */
/* cursor for looking at messages before actually getting them. In */
/* order to run the program, messages must already exist on the queue. */
/* */
/* The program will browse a message and then ask if the message should */
/* actually be retrieved. Any test string with a 'Y' or a 'y' will be */
/* taken as a yes and the message will be retrieved. */
/* */
/* The program can be run as follows */
/* */
/* java mqbrowse SYSTEM.DEFAULT.LOCAL.QUEUE */
/* */
/* This program has been tested with MQSeries V5.1 and JDK 1.1.7. */
/* */
/***************************************************************************/
/* */
/* mqbrowse has 2 parameters: */
/* queue name (required) */
/* queue manager name (optional) */
/* */
/***************************************************************************/
import com.ibm.mq.*; // Include the MQ package
import java.io.*;
import java.lang.*;

public class mqbrowse {

private MQQueueManager qMgr;

public static void main (String args[]) throws IOException {
/****************************************************************/
/* Check to make sure that at least the queue name was entered. */
/****************************************************************/
/* Note: By passing in command line arguments in this fashion, */
/* this program strays from the 100% Pure Java philosophy (not */
/* all OSs allow for arguments). However, the purpose of this */
/* program is to show the use of the MQSeries browsing not the */
/* use of Java argument passing. */
/****************************************************************/
if (args.length < 1) {
System.out.println("Required parameter missing - queue name");
} else {
System.out.println("mqbrowse: browse and optionally get messages");
mqbrowse mySample = new mqbrowse();
mySample.init();
mySample.start(args);
}
System.exit(0);
}

/**********************************************************/
/* This program doesn't have any specific initialization. */
/* If it did, it could go here. */
/**********************************************************/
public void init() {
}

public void start(String args[]) {
try {

/******************************************************/
/* Create a queue manager object and access the queue */
/* that will be used for the putting of messages. */
/******************************************************/
if (args.length > 1) {
qMgr = new MQQueueManager(args[1]);
} else {
qMgr = new MQQueueManager("");
}
int openOptions = MQC.MQOO_INPUT_EXCLUSIVE | MQC.MQOO_BROWSE;
MQQueue myQueue = qMgr.accessQueue(args[0], openOptions,
null, null, null);

/*****************************************/
/* Set up a reader to get the user input */
/*****************************************/
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String runShow;

/******************************************************/
/* Set up our options to browse for the first message */
/******************************************************/
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = MQC.MQGMO_WAIT | MQC.MQGMO_BROWSE_FIRST + MQC.MQGMO_LOCK; // <-- lock option added
MQMessage myMessage = new MQMessage();

/***************************/
/* Set up a loop exit flag */
/***************************/
boolean done = false;
do {
try {
/*****************************************/
/* Reset the message and IDs to be empty */
/*****************************************/
myMessage.clearMessage();
myMessage.correlationId = MQC.MQCI_NONE;
myMessage.messageId = MQC.MQMI_NONE;

/**************************************************/
/* Browse the message, display it, and ask if the */
/* message should actually be gotten */
/**************************************************/
myQueue.get(myMessage, gmo);
String msg = myMessage.readString(myMessage.getMessageLength());
System.out.println("Browsed message: " + msg);
System.out.println("Actually get message?");
runShow = br.readLine();
if (runShow.length() > 0) {
if ( (runShow.indexOf("Y") != -1)
|| (runShow.indexOf("y") != -1) ) {
System.out.println("Actually getting the message");
gmo.options = MQC.MQGMO_MSG_UNDER_CURSOR;
myQueue.get(myMessage, gmo);
}
}

/************************************************/
/* Reset the options to browse the next message */
/************************************************/
gmo.options = MQC.MQGMO_WAIT | MQC.MQGMO_BROWSE_NEXT;
} catch (MQException ex) {
/**************************************************/
/* Probably encountered our no message available: */
/* write out error and mark loop to be exited */
/**************************************************/
System.out.println("MQ exception: CC = " + ex.completionCode
+ " RC = " + ex.reasonCode);
done = true;
} catch (java.io.IOException ex) {
System.out.println("Java exception: " + ex);
done = true;
}

} while (!done);


/**********************************************************/
/* Before the program ends, the open queue will be closed */
/* and the queue manager will be disconnected. */
/**********************************************************/
myQueue.close();
qMgr.disconnect();
}
catch (MQException ex) {
System.out.println("MQ exception: CC = " + ex.completionCode
+ " RC = " + ex.reasonCode);
}
}

}
Back to top
View user's profile Send private message
mqonnet
PostPosted: Mon Jun 03, 2002 5:39 am    Post subject: Reply with quote

Grand Master

Joined: 18 Feb 2002
Posts: 1114
Location: Boston, Ma, Usa.

I did not check it out using java. But sure it will work there too.

I have 2 suggestions though.
1) Try the same scenario with a C/C++ sample program and see if it works or not.
2) Check out if your JVM is properly linked to the appropriate libraries. What version of NSJ are you using. Did you recreate your own JVM as per the readme supplied with NSJ.

NOTE: If #1 works, then the problem lies with your JVM. Check #2 for the same.

Hope this helps.

Cheers.
Kumar
_________________
IBM Certified WebSphere MQ V5.3 Developer
IBM Certified WebSphere MQ V5.3 Solution Designer
IBM Certified WebSphere MQ V5.3 System Administrator
Back to top
View user's profile Send private message Send e-mail Visit poster's website
robsdman
PostPosted: Tue Sep 21, 2004 2:37 pm    Post subject: fyi Reply with quote

Apprentice

Joined: 23 Aug 2002
Posts: 27

Only the first browsed message is locked. To lock the remaining messages as they are browsed, MQC.MQGMO_LOCK probably should be specified on the second gmo browse options too.
Back to top
View user's profile Send private message
ewsachse
PostPosted: Thu Dec 02, 2004 8:25 am    Post subject: Reply with quote

Newbie

Joined: 02 Dec 2004
Posts: 3

It does work. I use it with one of our MQ applications, and it is coded in Java.
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 » Reason 2046..., browse and lock, does it really work?
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.