Return-Path: Delivered-To: apmail-activemq-users-archive@www.apache.org Received: (qmail 37350 invoked from network); 29 Apr 2009 06:31:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 29 Apr 2009 06:31:52 -0000 Received: (qmail 37611 invoked by uid 500); 29 Apr 2009 06:31:51 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 37536 invoked by uid 500); 29 Apr 2009 06:31:51 -0000 Mailing-List: contact users-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@activemq.apache.org Delivered-To: mailing list users@activemq.apache.org Received: (qmail 37525 invoked by uid 99); 29 Apr 2009 06:31:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Apr 2009 06:31:51 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of roger.hoover@gmail.com designates 209.85.198.251 as permitted sender) Received: from [209.85.198.251] (HELO rv-out-0708.google.com) (209.85.198.251) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Apr 2009 06:31:45 +0000 Received: by rv-out-0708.google.com with SMTP id f25so622784rvb.26 for ; Tue, 28 Apr 2009 23:31:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=yfhSCyjjCog2TYg2/GWVs86ZW7iAgLmsioIQMa+pfr4=; b=QFYcEW3qzoS+VpMoM96+I1rNPCq3ByyxEX17clHY8p23XFc0gpoW6t/y5k9U6LLBh+ itlEHA1hLt4SSTIJfkE8oAZhVNfYrpmc5qohFAB8SWa/iCi4NsP/yDgIvVU9kfBbAP2H xUZNdckVl+DKvQJHyHs9B82oV6OlH/kTzfnvk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=UDYawClhyEYKKi+QSRWFU0ntG78XpauVPje7oQIK5I0+Mq0dqmCFOw/9YXdLN7D75E TqJNXsdTBHDseMbrKIz0tVPZcxOlPc+BxynwL3mwdy1xEKCM8sTbzXILcazTtCaIyFGS DQZroXMqJ55sIkyk24igE7uyZuKqoL+IVWd/s= MIME-Version: 1.0 Received: by 10.142.156.19 with SMTP id d19mr1704700wfe.6.1240986685233; Tue, 28 Apr 2009 23:31:25 -0700 (PDT) In-Reply-To: <82589C2D-7552-46F4-8F44-8AD9A72C61A6@soa-knowledge.net> References: <44cb1ba30904281515h63874256v8fdff66699ea78f0@mail.gmail.com> <82589C2D-7552-46F4-8F44-8AD9A72C61A6@soa-knowledge.net> Date: Tue, 28 Apr 2009 23:31:25 -0700 Message-ID: <44cb1ba30904282331s32ad876fsf48d296c98251b0f@mail.gmail.com> Subject: Re: Queue message order From: Roger Hoover To: users@activemq.apache.org Content-Type: multipart/alternative; boundary=000e0cd17b9a8b5ce60468abba92 X-Virus-Checked: Checked by ClamAV on apache.org --000e0cd17b9a8b5ce60468abba92 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi Andreas, That's an insightful question and there is a good answer, albeit complicated. The test is trying to validate the exception handling logic in our STOMP client. To prevent the poison pill problem where the same bad message gets redelivered over and over in an infinite loop, the logic for a message that causes an exception is to 1) ACK the offending message to the broker, 2) send it to an error queue, 3) disconnect cleanly from the broker (to prevent a bug in AMQ 4 which does not release the thread if the connection is not closed cleanly), and then 4) rethrow the original exception. The unit test requires two distinct messages. The client purposely throws an exception trying to handle the first message and the second message is necessary to verify #1 above. If msg 1 was ACK'ed, msg 2 will be next in the queue. This is why two distinct messages are required to be delivered in order for the test. Cheers, Roger On Tue, Apr 28, 2009 at 10:42 PM, Andreas Gies wrote: > Hi Roger, > > may be I missed something, but if the application doesn't need the > messages to be in order, why are you testing for it ? > > Just wondering > Andreas > > > On Apr 29, 2009, at 12:15 AM, Roger Hoover wrote: > > Hi, >> >> Are queued messages supposed to be delivered in order? I have a simple >> STOMP Perl script below that shows messages delivered out of order. I've >> run it against AMQ 4.1.1 and 5.2.0 in with both persistent and >> non-persistent messages. Note from the message ids and timestamps that >> the >> newer message is delivered first. >> >> Is there a way to force message delivery order? I don't think selectors >> allow for ordering, right? Our application doesn't particularly depend on >> message order but this behavior is causing my unit tests to fail every >> third >> time they are run. :( >> >> This also seems problematic for STOMP clients using "client" ack mode. >> Since newer messages are delivered first, ack'ing the newer message will >> implicitly ack the older message which has not even been delivered yet. >> >> Any help is appreciated. Thanks, >> >> Roger >> >> $ perl out-of-order.pl >> OUT OF ORDER!!! >> Frame 1: $VAR1 = bless( { >> 'body' => 'test2', >> 'headers' => { >> 'priority' => '0', >> 'timestamp' => '1240956094252', >> 'destination' => '/queue/testOutOfOrder', >> 'message-id' => >> 'ID:thedude.local-58168-1240956067250-3:3897:-1:1:2', >> 'expires' => '0' >> }, >> 'command' => 'MESSAGE' >> }, 'Net::Stomp::Frame' ); >> Frame 2: $VAR1 = bless( { >> 'body' => 'test1', >> 'headers' => { >> 'priority' => '0', >> 'timestamp' => '1240956094247', >> 'destination' => '/queue/testOutOfOrder', >> 'message-id' => >> 'ID:thedude.local-58168-1240956067250-3:3897:-1:1:1', >> 'expires' => '0' >> }, >> 'command' => 'MESSAGE' >> }, 'Net::Stomp::Frame' ); >> >> #!/usr/bin/env perl >> >> use strict; >> use Net::Stomp; >> use Data::Dumper; >> >> my $stomp = Net::Stomp->new( { 'hostname' => 'localhost', 'port' => >> '61613' >> } ); >> $stomp->connect( { 'login' => 'hello', 'passcode' => 'there' } ); >> $stomp->subscribe( >> { 'destination' => '/queue/testOutOfOrder', >> 'ack' => 'client', >> 'activemq.prefetchSize' => 1 >> } >> ); >> while ($stomp->can_read({'timeout' => 1})) { >> my $frame = $stomp->receive_frame(); >> $stomp->ack({'frame' => $frame}); >> } >> $stomp->disconnect(); >> >> while (1) { >> doit(); >> } >> >> sub doit { >> my $stomp = Net::Stomp->new( { 'hostname' => 'localhost', 'port' => >> '61613' } ); >> $stomp->connect( { 'login' => 'hello', 'passcode' => 'there' } ); >> >> $stomp->send({ 'destination' => '/queue/testOutOfOrder', 'body' => >> 'test1', 'persistent' => 'true'} ); >> $stomp->send({ 'destination' => '/queue/testOutOfOrder', 'body' => >> 'test2', 'persistent' => 'true'} ); >> $stomp->disconnect(); >> >> my $stomp = Net::Stomp->new( { 'hostname' => 'localhost', 'port' => >> '61613' } ); >> $stomp->connect( { 'login' => 'hello', 'passcode' => 'there' } ); >> $stomp->subscribe( >> { 'destination' => '/queue/testOutOfOrder', >> 'ack' => 'client', >> 'activemq.prefetchSize' => 1 >> } >> ); >> my $frame1 = $stomp->receive_frame(); >> $stomp->ack({'frame' => $frame1}); >> my $frame2 = $stomp->receive_frame(); >> $stomp->ack({'frame' => $frame2}); >> $stomp->disconnect(); >> >> if ($frame1->{'body'} ne 'test1') { >> print "OUT OF ORDER!!!\n"; >> print "Frame 1: " . Dumper($frame1); >> print "Frame 2: " . Dumper($frame2); >> } >> } >> > > --000e0cd17b9a8b5ce60468abba92--