ActiveMQ (was Re: Devel::Cover with Moose?)

Toby Wintermute tjc at wintrmute.net
Wed May 25 03:57:23 BST 2011


On 24 May 2011 19:53, Toby Wintermute <tjc at wintrmute.net> wrote:
> On 24 May 2011 15:18, Toby Wintermute <tjc at wintrmute.net> wrote:
>> On 23 May 2011 21:07, Peter Edwards <peter at dragonstaff.co.uk> wrote:
>>> Back to fighting with ActiveMQ. Feh.
>>
>> By the way.. how are you finding ActiveMQ, especially when interacting
>> with it from Perl?
>
> Answering my own question a bit here, but I have now used ActiveMQ
> with Perl via the STOMP interface to ActiveMQ.
>
> 1) I've already had to file two bugs with patches to AnyEvent::STOMP,
> as it simply didn't work at all. This is possibly due to a stricter
> parsing of STOMP by ActiveMQ than others.. I'm not sure.
> It doesn't give me much confidence that anyone else is working with
> both ActiveMQ and this CPAN module though!
>
> 2) The ACK system seems to be ignored by ActiveMQ.
> I set "ACK"s to be manual, and then I am only sending ACKs for 50% of
> the messages I receive.
> I am setting the Receipt header in messages I send.
>
> So, I expect that either
> a) I will not receipt RECEIPTs for things I didn't ACK, or
> b) The broker will resend messages that I failed to ACK.
>
> Neither of these happen.
> I receive RECEIPTs for every message sent, and un-ACKed messages are
> not requeued.
>
> Is that meant to happen?

Quickly updating this -- further investigation shows that ActiveMQ's
behaviour is to take any ACK to mean you're acknowledging everything
sent so far. If you don't ACK anything, or the recent things, then
it'll happily store and resend them.

So if I receive 10 messages, and sent ACKs for none except the last,
then all are considered good by activemq. Nothing will be requeued.

If I receive 10 messages, and send ACKs for, say, #8, but not #9 or
#10, then activemq will consider the first 8 as good, and requeue and
resend the ninth and tenth.

So if you're using ACKs to indicate that you haven't totally crashed
while processing a message, then the system will work as you expect..
if you crash and reconnect, you'll receive the last message again.

This is a bit annoying if you're writing an asynchronous consumer with
AnyEvent::STOMP though, because you could conceivably receive 3
messages and be processing them simultaneously.. finish #3 first and
ACK it, then crash out before finishing #1 and #2. But because you
ACKed #3, ActiveMQ considers 1 and 2 as fine too :(

Note that I am a newbie at AMQ so it's possible there's some sort of
option floating around to change this that I just haven't found yet..

-Toby


More information about the london.pm mailing list