Return-Path: X-Original-To: apmail-activemq-users-archive@www.apache.org Delivered-To: apmail-activemq-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8A8C07691 for ; Tue, 15 Nov 2011 11:10:03 +0000 (UTC) Received: (qmail 10855 invoked by uid 500); 15 Nov 2011 11:10:03 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 10828 invoked by uid 500); 15 Nov 2011 11:10:03 -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 10820 invoked by uid 99); 15 Nov 2011 11:10:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Nov 2011 11:10:03 +0000 X-ASF-Spam-Status: No, hits=0.6 required=5.0 tests=FREEMAIL_FROM,HS_INDEX_PARAM,RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of gary.tully@gmail.com designates 209.85.213.171 as permitted sender) Received: from [209.85.213.171] (HELO mail-yx0-f171.google.com) (209.85.213.171) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Nov 2011 11:09:57 +0000 Received: by yenl7 with SMTP id l7so2602911yen.2 for ; Tue, 15 Nov 2011 03:09:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=9TvlgnklxGrhVAuMAm7sHMQmKgNGVmimyj9iq7f22Ao=; b=vlyU4zNKukpDWq7j+v4LTJgn/An0UxandmcBXKMJDqqSJsJ/8nAB2xCWusC0AmgPn6 mus4EOexDTcZQpn5b0IpqCOe86nQBk08c361Z78aig4oHUEgXC/7JcRKQwcXQQ7nvAha /J/zLmU46Car5BEysrnNaQihykPCjaPio0jfY= MIME-Version: 1.0 Received: by 10.224.183.145 with SMTP id cg17mr16332590qab.71.1321355377157; Tue, 15 Nov 2011 03:09:37 -0800 (PST) Received: by 10.229.181.138 with HTTP; Tue, 15 Nov 2011 03:09:36 -0800 (PST) In-Reply-To: <1321291981661-4040260.post@n4.nabble.com> References: <1321291981661-4040260.post@n4.nabble.com> Date: Tue, 15 Nov 2011 11:09:36 +0000 Message-ID: Subject: Re: Message priority From: Gary Tully To: users@activemq.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable hmm. that is a problem. If you use persistent delivery, DeliveryMode.PERSISTENT or pass -Ddurable=3Dtrue to the ant producer task, the priority order will be respected. I ran a quick variant of the org.apache.activemq.store.MessagePriorityTest.testQueues from activemq-core with non persistent delivery and it fails. Can you raise a jira issue to track this. It needs a bit of investigation to see why sorting is being bypassed for non persistent messages. On 14 November 2011 17:33, Mihai Osian wrote: > =A0Hello, > > =A0I am trying to enable priority consumption and I can't seem to get it > working right. I am using ActiveMQ version 5.5.1 and I have followed the > instructions from > http://activemq.apache.org/how-can-i-support-priority-queues.html. > =A0For testing I modified the example code that comes with ActiveMQ itsel= f so > that the ProducerTool sends 180 messages with cycling priority > (0,1,..8,0,1,2...). After the producer finishes the job I start the consu= mer > and look at the order in which the messages are received. The first few > messages are sometimes received in an apparently random order, after whic= h > they start coming in descending order of their priority, as I expect. > =A0I have also discovered that if I set queuePrefetch=3D"1" in the > "policyEntry" element from the XML configuration file I get an unsorted > list. Similarly, setting it to 3 (for example) results in the output list > being thoroughly randomized (messages are presumably sorted in groups of = 3, > but not quite). > > =A0My questions are: > 1. Can somebody explain the results I see ? Am I missing something ? > 2. Is there a way to get the all messages fully sorted in descending orde= r, > assuming one single consumer that is started after all messages are in th= e > queue ? > 3. The ActiveMQ documentation page (written for version 5.4) that I > mentioned above says that KahaDB supports 3 levels of priority (<5, 5, an= d >>5). However: > =A0 3a. The first few messages that I get are sometimes low-priority (<5)= . > =A0 3b. With a larger queuePrefetch most messages are fully sorted in > descending order, so it may be that the page is out of date and in the > latest version it is supposed to support the full priority range. Still, = I > don't understand the output. > > Other technical information: > - ActiveMQ 5.5.1 (also tested 5.5.0, same behavior) > - activemq started from the command line with: > =A0 ./bin/activemq console xbean:conf/activemq-priority.xml > The activemq-priority.xml is a copy of the conf/activemq.xml, plus the > following entry: > =A0 queuePrefetch=3D"200" producerFlowControl=3D"true" > memoryLimit=3D"1mb"> > - A modified version of the ActiveMQ example (also containing the > activemq-priority.xml file) can be found here: > http://www.mediafire.com/?z7u5fhhlfbt3ano , if anybody wants to check the > code. > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > An example output copy-pasted from my console: > > mike@dell:~/tmp/apache-activemq-5.5.0/example$ ant producer > Buildfile: /home/mike/tmp/apache-activemq-5.5.0/example/build.xml > > init: > > compile: > =A0 =A0[javac] /home/mike/tmp/apache-activemq-5.5.0/example/build.xml:152= : > warning: 'includeantruntime' was not set, defaulting to > build.sysclasspath=3Dlast; set to false for repeatable builds > > producer: > =A0 =A0 [echo] Running producer against server at $url =3D tcp://localhos= t:61616 > for subject $subject =3D TEST.FOO > =A0 =A0 [java] Connecting to URL: tcp://localhost:61616 > =A0 =A0 [java] Publishing a Message with size 1000 to queue: TEST.FOO > =A0 =A0 [java] Using non-persistent messages > =A0 =A0 [java] Sleeping between publish 0 ms > =A0 =A0 [java] Running 1 parallel threads > =A0 =A0 [java] [Thread-1] Sending message: 'Message with priority: 0 inde= x: 0 > sent at: Mon Nov...' with priority 0 > =A0 =A0 [java] [Thread-1] Sending message: 'Message with priority: 1 inde= x: 1 > sent at: Mon Nov...' with priority 1 > =A0 =A0 [java] [Thread-1] Sending message: 'Message with priority: 2 inde= x: 2 > sent at: Mon Nov...' with priority 2 > =A0 =A0 [java] [Thread-1] Sending message: 'Message with priority: 3 inde= x: 3 > sent at: Mon Nov...' with priority 3 > =A0 =A0 [java] [Thread-1] Sending message: 'Message with priority: 4 inde= x: 4 > sent at: Mon Nov...' with priority 4 > =A0 =A0 [java] [Thread-1] Sending message: 'Message with priority: 5 inde= x: 5 > sent at: Mon Nov...' with priority 5 > =A0 =A0 [java] [Thread-1] Sending message: 'Message with priority: 6 inde= x: 6 > sent at: Mon Nov...' with priority 6 > =A0 =A0 [java] [Thread-1] Sending message: 'Message with priority: 7 inde= x: 7 > sent at: Mon Nov...' with priority 7 > =A0 =A0 [java] [Thread-1] Sending message: 'Message with priority: 8 inde= x: 8 > sent at: Mon Nov...' with priority 8 > =A0 =A0 [java] [Thread-1] Sending message: 'Message with priority: 0 inde= x: 9 > sent at: Mon Nov...' with priority 0 > =A0 =A0 [java] [Thread-1] Sending message: 'Message with priority: 1 inde= x: 10 > sent at: Mon No...' with priority 1 > =A0 =A0 [java] [Thread-1] Sending message: 'Message with priority: 2 inde= x: 11 > sent at: Mon No...' with priority 2 > =A0 =A0 [java] [Thread-1] Sending message: 'Message with priority: 3 inde= x: 12 > sent at: Mon No...' with priority 3 > =A0 =A0 [java] [Thread-1] Sending message: 'Message with priority: 4 inde= x: 13 > sent at: Mon No...' with priority 4 > =A0 =A0 [java] [Thread-1] Sending message: 'Message with priority: 5 inde= x: 14 > sent at: Mon No...' with priority 5 > =A0 =A0 [java] [Thread-1] Sending message: 'Message with priority: 6 inde= x: 15 > sent at: Mon No...' with priority 6 > =A0 =A0... > > mike@dell:~/tmp/apache-activemq-5.5.0/example$ ant consumer > Buildfile: /home/mike/tmp/apache-activemq-5.5.0/example/build.xml > > init: > > compile: > =A0 =A0[javac] /home/mike/tmp/apache-activemq-5.5.0/example/build.xml:152= : > warning: 'includeantruntime' was not set, defaulting to > build.sysclasspath=3Dlast; set to false for repeatable builds > > consumer: > =A0 =A0 [echo] Running consumer against server at $url =3D tcp://localhos= t:61616 > for subject $subject =3D TEST.FOO > =A0 =A0 [java] Connecting to URL: tcp://localhost:61616 > =A0 =A0 [java] Consuming queue: TEST.FOO > =A0 =A0 [java] Using a non-durable subscription > =A0 =A0 [java] JMS Selector > =A0 =A0 [java] Running 1 parallel threads > =A0 =A0 [java] [Thread-1] We are about to wait until we consume: 180 mess= age(s) > then we will shutdown > =A0 =A0 [java] [Thread-1] Received: 'Message with priority: 7 index: 7 se= nt at: > Mon Nov...' (length 1000) > =A0 =A0 [java] [Thread-1] Received: 'Message with priority: 8 index: 8 se= nt at: > Mon Nov...' (length 1000) > =A0 =A0 [java] [Thread-1] Received: 'Message with priority: 8 index: 17 s= ent > at: Mon No...' (length 1000) > =A0 =A0 [java] [Thread-1] Received: 'Message with priority: 7 index: 16 s= ent > at: Mon No...' (length 1000) > =A0 =A0 [java] [Thread-1] Received: 'Message with priority: 6 index: 6 se= nt at: > Mon Nov...' (length 1000) > =A0 =A0 [java] [Thread-1] Received: 'Message with priority: 6 index: 15 s= ent > at: Mon No...' (length 1000) > =A0 =A0 [java] [Thread-1] Received: 'Message with priority: 5 index: 5 se= nt at: > Mon Nov...' (length 1000) > =A0 =A0.... > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > Thanks in advance, > Mihai > > http://activemq.2283324.n4.nabble.com/file/n4040260/example.tgz example.t= gz > > > -- > View this message in context: http://activemq.2283324.n4.nabble.com/Messa= ge-priority-tp4040260p4040260.html > Sent from the ActiveMQ - User mailing list archive at Nabble.com. > --=20 http://fusesource.com http://blog.garytully.com