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 » Exculsive access to MQ queue using java code

Post new topic  Reply to topic
 Exculsive access to MQ queue using java code « View previous topic :: View next topic » 
Author Message
abhishek
PostPosted: Mon May 10, 2010 3:04 am    Post subject: Exculsive access to MQ queue using java code Reply with quote

Newbie

Joined: 10 May 2010
Posts: 3

Hi,

I have a java program which process messages and put into a MQ queue.some times i get some extra messages in that queue,which could be because of some other program might be using that queue and pushing some messages in that.

I just want to know is there any way by which i can check which else program is trying to access the queue during my program run.Do I have any way by which I
can get exclusive access to the MQ queue while my program execution, which in turn will ensure that there would not be any extra messages in that queue.

I am using IBM mq 5.3 and java 1.6.

I need to do this using java program as I don't have access to MQ.



Regards,
Abhishek
Back to top
View user's profile Send private message
mvic
PostPosted: Mon May 10, 2010 3:07 am    Post subject: Re: Exculsive access to MQ queue using java code Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

abhishek wrote:
some times i get some extra messages in that queue

Please explain, why is that a problem?

You can inspect the connections etc. using

DISPLAY CONN
DISPLAY QSTATUS
Back to top
View user's profile Send private message
abhishek
PostPosted: Mon May 10, 2010 3:54 am    Post subject: Exculsive access to MQ queue using java code Reply with quote

Newbie

Joined: 10 May 2010
Posts: 3

I have a program which processes the messages and gives me count of all the messages from a specific MQ queue. Say I run that and expect 10 messages in response, I use to get 10.Now if do a test for a huge data and I expect 10,000 messages, I used to get 10,027 (say). Now I don’t know where are these extra messages from so, I need to know is there any other program which has accessed to that particular queue while my program was executing. If so, how would I restrict that program to access the same queue in my java code?
Back to top
View user's profile Send private message
mvic
PostPosted: Mon May 10, 2010 4:04 am    Post subject: Re: Exculsive access to MQ queue using java code Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

abhishek wrote:
I have a program which processes the messages and gives me count of all the messages from a specific MQ queue. Say I run that and expect 10 messages in response, I use to get 10.Now if do a test for a huge data and I expect 10,000 messages, I used to get 10,027 (say). Now I don’t know where are these extra messages from so, I need to know is there any other program which has accessed to that particular queue while my program was executing. If so, how would I restrict that program to access the same queue in my java code?

This sounds like a non-optimal use of MQ.

In the best-case use of MQ, each message should stand alone. The app should get a message, process it, and move to the next.

Admittedly there are other patterns of usage that are valid, but not many.

You don't say why the app needs to count the messages, but I doubt it is a very useful thing for the app to know how many messages are on the queue.

If you want to group messages and process them as if they were a single piece of information, there is GroupId and CorrelId to help you do this.
Back to top
View user's profile Send private message
abhishek
PostPosted: Mon May 10, 2010 4:28 am    Post subject: Reply with quote

Newbie

Joined: 10 May 2010
Posts: 3

Sorry, let me try again.

I have a java program which process messages from a MQ queue. Some times i don't get all of the messages that I'm expecting from that queue, which could be because of some other program reading from that queue and pulling my messages off of it.

I just want to know is there any way by which i can check which else program (or at least which machine the program is running on) is trying to access the queue during my program run. Alternatively, do I have any way by which I can get exclusive access to the MQ queue while my program is executing?

Thank you very much.
Back to top
View user's profile Send private message
mvic
PostPosted: Mon May 10, 2010 4:41 am    Post subject: Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

abhishek wrote:
I just want to know is there any way by which i can check which else program (or at least which machine the program is running on) is trying to access the queue during my program run.

You can inspect the connections etc. using

DISPLAY CONN
DISPLAY QSTATUS

Quote:
Alternatively, do I have any way by which I can get exclusive access to the MQ queue while my program is executing?

Yes, you can use MQOO_INPUT_EXCLUSIVE.
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon May 10, 2010 9:38 am    Post subject: Reply with quote

Grand High Poobah

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

abhishek wrote:
Alternatively, do I have any way by which I can get exclusive access to the MQ queue while my program is executing?


Not if another application is already connected to the queue and reading messages.

If no other application should be reading messages off this queue, then the user id your application runs under should be the only one granted authority to read messages. This is the most efficient way of solving your problem, and doesn't require a single line of code be changed!
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon May 10, 2010 11:19 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Vitor wrote:
abhishek wrote:
Alternatively, do I have any way by which I can get exclusive access to the MQ queue while my program is executing?


Not if another application is already connected to the queue and reading messages.

If no other application should be reading messages off this queue, then the user id your application runs under should be the only one granted authority to read messages. This is the most efficient way of solving your problem, and doesn't require a single line of code be changed!

And remember in a Unix environment all authorizations are made at the group id level. There is no such thing as setting the authorisations at a userid level in Unix...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Exculsive access to MQ queue using 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.