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 » get most recent message in the Queue

Post new topic  Reply to topic
 get most recent message in the Queue « View previous topic :: View next topic » 
Author Message
himansupanda
PostPosted: Fri Jan 25, 2008 10:45 am    Post subject: get most recent message in the Queue Reply with quote

Newbie

Joined: 25 Jan 2008
Posts: 2

Hi,

I have an requirement to read the most recent message put on the queue. Please Let me know How to do that using MQ JAVA API.

Thanks in advance,

Regards
Himansu
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri Jan 25, 2008 1:39 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

A queue is a first-in, first-out structure.

Your requirement is entirely wrong.

Any attempt to do this will lead to horrible performance issues and horrible stability issues, as well as breaking the "loose coupling" that MQ provides.

You need to re-examine the requirement that says that you must read a queue in last-in, first-out order. And then figure out what it's really trying to do, and a better way to do it.

If you at least post what the requirement is really trying to do, we can help you figure out a better way to do it.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Jan 25, 2008 4:16 pm    Post subject: Re: get most recent message in the Queue Reply with quote

Grand High Poobah

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

himansupanda wrote:
I have an requirement to read the most recent message put on the queue.


Strange requirement. What happens to the other messages on the queue if you only read the most recent? Suppose 3 messages turn up in a block, what processes the other 2?


_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sat Jan 26, 2008 11:50 am    Post subject: Reply with quote

Grand High Poobah

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

Retained publication syndrome ?
For lack of language skills:
retained publication = last message in queue??
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
himansupanda
PostPosted: Mon Jan 28, 2008 6:46 am    Post subject: Reply with quote

Newbie

Joined: 25 Jan 2008
Posts: 2

Hi,

Thanks for reply....

Requirement is like this. Some other application is sending message continuesly to our local Q. Our application needs only the Most recent message on demand. Message contains some live data. Everytime there is some changes in Message.This application doe not require all the messge, as it wants latest data.

Please let me know if any other solution.

Regards
Himansu
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Jan 28, 2008 6:54 am    Post subject: Reply with quote

Grand High Poobah

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

himansupanda wrote:
This application doe not require all the messge, as it wants latest data.


What you're describing is best satisfied by the suggestion of fjb_saper, a retained publication.

If (and only if) the data is sent continiously and on a regular cycle (e.g. every 60 seconds) then an alternative would be to set the expiry of the message to just under the cycle time (59 seconds in my example) so there's only ever 1 message on the queue and it's always the latest.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Jan 28, 2008 7:12 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

The other alternative is to continually consume the messages, and cache the data of the last message read. Then "on demand", show the value from the cache.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
PeterPotkay
PostPosted: Mon Jan 28, 2008 10:35 am    Post subject: Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7722

another cheesy way would be for the putting app to delete its last message by doing a destructive get before putting the newest one back on the queue. Not as ideal or elegant as retained pubs, but maybe easier if there is no need to scale and this is just a one time low volume requirement.
_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Jan 28, 2008 10:42 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

PeterPotkay wrote:
another cheesy way would be for the putting app to delete its last message by doing a destructive get


Only if the putting app is capable of doing any kind of GET from the destination queue...
_________________
I am *not* the model of the modern major general.
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 » get most recent message in the 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.