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 Check a MQ Q exists or not??

Post new topic  Reply to topic
 How To Check a MQ Q exists or not?? « View previous topic :: View next topic » 
Author Message
meriton
PostPosted: Wed Jan 07, 2004 8:08 pm    Post subject: How To Check a MQ Q exists or not?? Reply with quote

Novice

Joined: 07 Aug 2002
Posts: 24

I am trying to move msgs from a queue to a list of dynamic queues. To do so, I need to check if the dynamic queue exists first, if yes, I open the queue and move the msgs, if not, I will create the dynamic queue then move the msg. I use accessQueue method to do the check, get an 2085 error every time if no such queue. Any efficient way to check if a dynamic queue exists ( queue name provided).


Follows the code I am using ..


boolean vExisting = false;
String dynamicQName = "CLK.G2B.PHY.DEVL.ISS." + pBatchId;
if (mQMgr != null) {
try {
int vOpenOptions = MQC.MQOO_BROWSE | MQC.MQOO_FAIL_IF_QUIESCING;
MQQueue DynamicQ =
mQMgr.accessQueue(
dynamicQName,
vOpenOptions,
null,
null,
null);
//testing...
if (DynamicQ != null)
vExisting = true;
//end testing...
} catch (MQException MQe) {
if (MQe.reasonCode != 2085)
throw MQe;

} catch (Exception e) {
throw e;

}
Code:


TIA
Back to top
View user's profile Send private message
bower5932
PostPosted: Thu Jan 08, 2004 6:27 am    Post subject: Reply with quote

Jedi Knight

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

You could use the PCF interface to get back a list of the queues. For java, you'll need SupportPac MS0B:

http://www-306.ibm.com/software/integration/support/supportpacs/individual/ms0b.html

I believe the Inquire Queue command with an '*' specified for the queue names is what you might want.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
clindsey
PostPosted: Thu Jan 08, 2004 6:53 am    Post subject: Reply with quote

Knight

Joined: 12 Jul 2002
Posts: 586
Location: Dallas, Tx

IMHO, if your intent is to write to the queue if it exists, then the most efficient check is to open the queue. If it exists, you have a valid handle and off you go. If it doesn't exist, then create it. Why spend cycles on a query function that still requires you to follow up with an open anyway?

Put a try/catch specifically around the queue open call and do the open in the catch block when 2085 is thrown. Then you can use the same code flow beyond that for either case.

Hope this helps,
Charlie
Back to top
View user's profile Send private message
bower5932
PostPosted: Thu Jan 08, 2004 7:59 am    Post subject: Reply with quote

Jedi Knight

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

I definitely agree with Charlie's point. The only time the inquire might/would come in handy is if you have a large number of queues to try and you know that most of them aren't going to exist. You could get your list ahead of time to save on the opens of the non-existent ones.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » How To Check a MQ Q exists or not??
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.