You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Joseph North <jo...@gmail.com> on 2017/07/28 01:00:16 UTC

Last-Value Queues

I was modifying Artemis' last-value queue example and saw some unexpected
behavior (gist of the code I'm working with:
https://gist.github.com/jrnorth/3040ffc8755be66c0c3ca39285e602b9).

In this example, I sent a 4th and 5th message to exampleQueue after
receiving the sole message on the queue (the 3rd message). Then I receive
another message from the queue, but it's the 4th message. Since this is a
last-value queue, shouldn't I have received the 5th message?

I'm using Artemis 2.1.

Thanks,

Joe

Re: Last-Value Queues

Posted by Justin Bertram <jb...@redhat.com>.
I believe this is a side-effect of message buffering for consumers.  Once
the consumer is created and you invoke javax.jms.Connection.start() then
the consumer will start fetching messages from the broker to put into it's
local buffer (even before javax.jms.Consumer.receive() is invoked).
Because of this the 4th message isn't actually on the queue when the 5th
message arrives.  If you set invoke javax.jms.Connection.stop() before
sending the 4th and 5th messages and then javax.jms.Connection.start()
before the last javax.jms.Consumer.receive() you'll get the 5th message.


Justin

On Thu, Jul 27, 2017 at 8:00 PM, Joseph North <jo...@gmail.com> wrote:

> I was modifying Artemis' last-value queue example and saw some unexpected
> behavior (gist of the code I'm working with:
> https://gist.github.com/jrnorth/3040ffc8755be66c0c3ca39285e602b9).
>
> In this example, I sent a 4th and 5th message to exampleQueue after
> receiving the sole message on the queue (the 3rd message). Then I receive
> another message from the queue, but it's the 4th message. Since this is a
> last-value queue, shouldn't I have received the 5th message?
>
> I'm using Artemis 2.1.
>
> Thanks,
>
> Joe
>