Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2005

Tip: Looking for answers? Try searching our database.

JMS message "locking"?

Thread view: 
Scott Balmos - 08 Jun 2005 16:50 GMT
Hi all,

Yet another JMS-related question. Is it possible to have the queue
"lock" a JMS message? What I'm considering is JMS in a point-to-point
setup. My main app server sends control messages to management daemons
on other systems. See previous threads by me in the past few days for
background.

Now, to create a type of pseudo-transaction, based on feedback in the
other threads, my main app server would send a control message to the
queue for the service to control (say, queue MailingListMgmt, which is
watched by the daemons controlling the mailing list servers). This
message would be read by the mailing list management servers, and would
only be consumed (and taken out of the queue) if the operation was
successful.

But if I have, say, three mailing list servers, I only want one server
to attempt the operation at a time. E.g. Box 2 reads the mesasge from
the queue first. I'd like to know if it's possible for Box 2 to "lock"
the message in the queue so that Boxes 1 & 3 don't read it, unless the
operations failed on Box 2 and the message isn't consumed. Then Box 2
would "unlock" the message, letting one of the other boxes attempt the
operations.

Is this possible? I was hoping against setting up separate queues for
each physical machine, as then the app server would have to do all the
management of sending the message to one of the other boxes if the
operation failed, etc.

Thanks for any info!

--Scott
John Maline - 08 Jun 2005 21:18 GMT
> But if I have, say, three mailing list servers, I only want one server
> to attempt the operation at a time. E.g. Box 2 reads the mesasge from
[quoted text clipped - 3 lines]
> would "unlock" the message, letting one of the other boxes attempt the
> operations.

For queues, this is how it works naturally.  A message on a queue will
be received by one consumer only.  Regardless of how many consumers
there are.

As for locking/unlocking, there's no such concept.  There is the concept
of acknowledging a message.  That's where you tell JMS that you've
successfully processed the message.  There's an auto-acknowledge mode
where it happens automatically.  See
QueueConnection.createQueueSession().  The second parameter indicates if
you're in auto-acknowledge mode or not.

Topics work differently - a copy of the message is received by every
consumer.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.