Oldest message in queue

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Oldest message in queue

Quique
Hi,

I'm quite a begginer with active-mq. How can I use JMX/JMS in order to know what  is the oldest message in a queue and how much time is that message on the queue. Is that possible to implement ?

Thanks!

Quique
Reply | Threaded
Open this post in threaded view
|

Re: Oldest message in queue

Tobias Trelle
Quique wrote
How can I use JMX/JMS in order to know what  is the oldest message in a queue and how much time is that message on the queue. Is that possible to implement ?
Since a queue by default implements the FIFO pattern (First in, first out), the _current_ message read by the consumer will be the oldest one (as long as you don't use any selectors).

IIRC, the JMS header property JMSTimestamp records the date of message creation, see: http://download.oracle.com/javaee/1.4/tutorial/doc/JMS4.html#wp79302

HTH,
Tobias
Reply | Threaded
Open this post in threaded view
|

Re: Oldest message in queue

irieb
Yeah, sure this is old - but its a top search result when searching for this
problem.... this reply is wrong, the oldest message when using the queue
browser is the last one. What makes it worse is when there are over 200
messages, it is the default page size - other than statistics or jolokia i
do not believe there is a solution - sad!. AMQ - why not support message
ordering? weak...



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
Reply | Threaded
Open this post in threaded view
|

Re: Oldest message in queue

jbertram
> ...this reply is wrong, the oldest message when using the queue browser
is the last one.

By "the last one" do you mean the last one that was put in the queue?
Surely the last message put on the queue cannot be older than the messages
that were already in the queue before that message was put there.

The original answer is correct - the message at the "head" of the queue
(i.e. the one about to be consumed) is the oldest one in the queue.

> AMQ - why not support message ordering?

Can you elaborate on what you mean by "message ordering"?


Justin

On Thu, Apr 5, 2018 at 6:21 PM, irieb <[hidden email]> wrote:

> Yeah, sure this is old - but its a top search result when searching for
> this
> problem.... this reply is wrong, the oldest message when using the queue
> browser is the last one. What makes it worse is when there are over 200
> messages, it is the default page size - other than statistics or jolokia i
> do not believe there is a solution - sad!. AMQ - why not support message
> ordering? weak...
>
>
>
> --
> Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-
> f2341805.html
>
Reply | Threaded
Open this post in threaded view
|

Re: Oldest message in queue

Tim Bain
In reply to this post by irieb
On Thu, Apr 5, 2018 at 5:21 PM, irieb <[hidden email]> wrote:

> Yeah, sure this is old - but its a top search result when searching for
> this
> problem.... this reply is wrong, the oldest message when using the queue
> browser is the last one.



You say "the queue browser," which isn't very precise... Are we talking
about the capability of browsing messages in the web console, about the
"browse" task in the command-line admin tool, about browsing via a JMX
viewer such as JConsole, or something else entirely? If the web console,
the columns in the table are sortable, so any behavior you're describing is
purely the result of your own action (or inaction) -
https://imagebin.ca/v/3xPRqV8TsASp. If the admin tool's browse task, the
oldest entry in the list when I did it just now was the first one, at the
top of the output - https://pastebin.com/0mft5Mt4. If you meant browsing
via a JMX viewer, when I did it via JConsole the oldest was the first item
(#1 of 400 as displayed in JConsole) - https://imagebin.ca/v/3xPRkZLK8AJX.
So for the three interpretations of what you wrote that seem the most
likely to me, your description doesn't match the actual behavior (against a
5.14.5 broker, which is what I have installed at the moment). Can you
please be more specific about what you're saying the behavior of ActiveMQ
is in this case?

Moreover, there's no indication to me that the behavior of browsing a queue
is actually what Tobias Trelle was describing; to me, that message sounds
like he is describing the behavior of actually consuming from the queue
(which I would have said doesn't actually answer the OP's question). It's
all subject to interpretation since neither user has been active since 2010
so we can't ask them. But no matter whether Tobias was talking about
consumption or browsing, he's not wrong: he's unambiguously right for
message consumption, and he's right for the three forms of browsing that I
tested this evening, and not wrong for any use case I know of (other than
if you sort the web console incorrectly, which is just user error). So if
you've found some other means of browsing where message are returned out of
order, he might be only partially right, but he's not fully wrong, and we'd
still need to see whatever your browsing method was to understand if that
one really does behave incorrectly.



> What makes it worse is when there are over 200
> messages, it is the default page size - other than statistics or jolokia i
> do not believe there is a solution



You just listed one (JMX, via Jolokia) that does work and one more
(statistics) that might; I don't know the statistics plugin well enough to
be sure. Even ignoring the two others I mentioned that you didn't know
about, this is like saying "There's nowhere to drive my car other than the
road - sad!"



> - sad!. AMQ - why not support message
> ordering? weak...
>


In fact, we do, in both 5.x and Artemis.

In the future, you should be careful about lobbing accusations that seem to
be more an opportunity for you to vent than anything else, especially when
there's a risk that you might be wrong in what you're saying. If you've
found something you think might be a bug, we're happy to discuss, and to
fix any that turn out to actually be issues. But name-calling doesn't
generally win many people over, especially when you don't provide any
evidence for the claims you're making.

Tim
Reply | Threaded
Open this post in threaded view
|

Re: Oldest message in queue

irieb
Apologies!!! I had a really long day, the behavior is in fact exactly how you
describe it for using the javax.jms.QueueBrowser without a filter. I had a
requirement to both capture the oldest message and message count based on
priority (session.createBrowser(queueName, "JMSPriority = " + priority) for
a particular queue - this is what lead to my frustration. I should have been
more patient in elaborating my description. I am unsure whether this
functionality is supported using the QueueBrowser. I really appreciate your
time in responding, sorry about the venting.



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html