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 » WebSphere Message Broker (ACE) Support » Exclusive access to Queue

Post new topic  Reply to topic
 Exclusive access to Queue « View previous topic :: View next topic » 
Author Message
Prasi
PostPosted: Tue Nov 05, 2013 7:08 pm    Post subject: Exclusive access to Queue Reply with quote

Apprentice

Joined: 03 Aug 2011
Posts: 42

Hi,

I have a requirement of getting an exclusive access to a queue, put the message to that queue. Also, make sure that no other thread is accessing it. I am using MQQSO_EXCLUSIVE option,but still I am not able to succeed in it. Is there any other option that I need to in my java. Any help is greatly appreciated.

Thanks,
Prasi
Back to top
View user's profile Send private message
calanais
PostPosted: Wed Nov 06, 2013 1:25 am    Post subject: Reply with quote

Apprentice

Joined: 12 Mar 2010
Posts: 32

Could you explain how you have not been able to succeed? Also is this via JMS or the WMQ Base Java API?

Also why do you only want a single thread to access a queue at one time? Do you have some strict message ordering requirements?
Back to top
View user's profile Send private message
PaulClarke
PostPosted: Wed Nov 06, 2013 1:42 am    Post subject: Reply with quote

Grand Master

Joined: 17 Nov 2005
Posts: 1002
Location: New Zealand

Are you sure you mean MQQSO_EXCLUSIVE and not MQOO_INPUT_EXCLUSIVE ? Perhaps this is some use of MQQSO_EXCLUSIVE in the JMS world I was unaware of.

Cheers,
Paul.
_________________
Paul Clarke
MQGem Software
www.mqgem.com
Back to top
View user's profile Send private message Visit poster's website
Prasi
PostPosted: Wed Nov 06, 2013 7:28 am    Post subject: Reply with quote

Apprentice

Joined: 03 Aug 2011
Posts: 42

I am using WMQ Base Java API. When I use MQOO_INPUT_EXCLUSIVE I am getting 2042 error which is MQRC_OBJECT_IN_USE which my object is not. When I accessing the queue for the first time, I want my queue to be exclusive for this process and put the message to the queue.

Yes there is a strict message orfering requirements.
Back to top
View user's profile Send private message
PaulClarke
PostPosted: Wed Nov 06, 2013 8:00 am    Post subject: Reply with quote

Grand Master

Joined: 17 Nov 2005
Posts: 1002
Location: New Zealand

Ok, well at least you are using MQOO_INPUT_EXCLUSIVE which makes more sense. If you are getting MQRC_OBJECT_IN_USE then it suggests that someone is already using the queue. What do you see if you issue:

dis qstatus(QUEUENAME) type(handle)

Does it look like someone already has the queue?. Bear in mind that if you kill an application (or it dies without closing/disconnecting) then it can take quite a few seconds before the QM notices and releases the lock on the queue.

Cheers,
Paul
_________________
Paul Clarke
MQGem Software
www.mqgem.com
Back to top
View user's profile Send private message Visit poster's website
RogerLacroix
PostPosted: Sun Nov 10, 2013 9:19 pm    Post subject: Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3254
Location: London, ON Canada

Hi,

You keep talking about exclusive access and putting a message which made me think you are on the wrong track. You cannot have exclusive access to a queue for putting messages to the queue. When you open a queue with MQOO_OUTPUT (for output only) then it is opened as shared.
Code:
MQQueue queue = qMgr.accessQueue( outputQName,
                                   MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING,
                                   null,
                                   null,
                                   null );

Regards,
Roger Lacroix
Capitalware Inc.
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
Prasi
PostPosted: Thu Dec 12, 2013 11:35 am    Post subject: Reply with quote

Apprentice

Joined: 03 Aug 2011
Posts: 42

Sorry for the late reply. I am doing the below coding in my Java Compute node.
MQQueueManager qMgr = new MQQueueManager(qManager);
int openOptions=CMQC.MQOO_INPUT_EXCLUSIVE ;
MQMessage msg= new MQMessage();
MQQueue locQueue=qMgr.accessQueue(statusQueue, openOptions);
MQGetMessageOptions gmo=new MQGetMessageOptions();
locQueue.get(msg,gmo);
locQueue.close();
String msgText=msg.readStringOfCharLength(msg.getMessageLength());
System.out.println("The message in queue is"+msgText);
if(msgText.equalsIgnoreCase("AVAILABLE"))
{
int openOptions1 = CMQC.MQOO_OUTPUT;
locQueue = qMgr.accessQueue(statusQueue,openOptions1);
MQMessage msgtoput = new MQMessage();
MQPutMessageOptions pmo = new MQPutMessageOptions();
String msgtowrite =("LOCKED");
msgtoput.writeString(msgtowrite);
locQueue.put(msgtoput, pmo);
locQueue.close();
}
qMgr.disconnect();

My problem is when I am putting 4 messages continuously, only the first message gets processed. The rest of them fails telling that 2042 (Object in Use) error. When i do dis qstatus(queuename) type (handle) I can see the dataflowengine is holding the process. But I am using debugger when I am starting the flow. Is there any issues with the code? Can someone please explain?
Back to top
View user's profile Send private message
Prasi
PostPosted: Thu Dec 12, 2013 11:37 am    Post subject: Reply with quote

Apprentice

Joined: 03 Aug 2011
Posts: 42

Type on my previous post. I am not using debugger while putting messages to the queue. What is holding it and what can I do to avoid this problem?
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Dec 12, 2013 11:43 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Prasi wrote:
Sorry for the late reply. I am doing the below coding in my Java Compute node.


Why are you accessing a queue with a Java Compute Node? What's wrong with the supplied nodes?

It also doesn't work all that well, as you've discovered.You get problems with threading and transaction scope (as you've discovered)
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Prasi
PostPosted: Thu Dec 12, 2013 11:47 am    Post subject: Reply with quote

Apprentice

Joined: 03 Aug 2011
Posts: 42

I am using a global cache and the requirement is to use JCN. Is there any other way or is there any bug in my logic?
Back to top
View user's profile Send private message
JosephGramig
PostPosted: Thu Dec 12, 2013 1:30 pm    Post subject: Reply with quote

Grand Master

Joined: 09 Feb 2006
Posts: 1231
Location: Gold Coast of Florida, USA

Since this is a WMB JCN, then I would think this topic belongs in the WMB Forum...
Back to top
View user's profile Send private message AIM Address
Vitor
PostPosted: Fri Dec 13, 2013 5:31 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

JosephGramig wrote:
Since this is a WMB JCN, then I would think this topic belongs in the WMB Forum...




So Moved
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Dec 13, 2013 5:33 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Prasi wrote:
I am using a global cache and the requirement is to use JCN.


How does that extend to including queue access in the JCN?

Your design is flawed. Rethink.
_________________
Honesty is the best policy.
Insanity is the best defence.
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 » WebSphere Message Broker (ACE) Support » Exclusive access to 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.