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 8E29A100EF for ; Tue, 25 Feb 2014 01:31:28 +0000 (UTC) Received: (qmail 42967 invoked by uid 500); 25 Feb 2014 01:31:27 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 42871 invoked by uid 500); 25 Feb 2014 01:31:27 -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 42860 invoked by uid 99); 25 Feb 2014 01:31:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Feb 2014 01:31:27 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of suonayi@gmail.com designates 74.125.83.41 as permitted sender) Received: from [74.125.83.41] (HELO mail-ee0-f41.google.com) (74.125.83.41) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Feb 2014 01:31:21 +0000 Received: by mail-ee0-f41.google.com with SMTP id b15so1387522eek.0 for ; Mon, 24 Feb 2014 17:31:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=d9t0wGzPVx8/F/TUNkIcbCDCjXh1fKloSzNBCESXavk=; b=aeHvrTkigs4wfQfOWPmiIEdu9DyQU5BnBZ1UqqmQrzOlsxKiJCpdVdeWj4C11dpDIf D87QUHhYQ9x0ME+QxLZ63ksa/7Mng8Cg62pMcl4s3UrJlEdyMhSAKBaEVU2A61u8yWvC TiAmHmbfqgMz8q1K/rJeH13phLB2O2osooIaJ6AFGyXaMtNlXNB6zDlw1HQ7u53k/JiW Efp3uw6nOwv3jTm+Jt6Zzxf3QGbbw/9nxJ8Frj53ujAOlSGzwQroQT1n04aaNFAkhqd1 wqzQOs62jOcInbFL3gSw/91cIQshoCxrccKf/1l7aGmLJT9Db/lUHi9d4b+O3iu0tueC jL+g== MIME-Version: 1.0 X-Received: by 10.14.111.5 with SMTP id v5mr22809886eeg.11.1393291861215; Mon, 24 Feb 2014 17:31:01 -0800 (PST) Received: by 10.14.143.76 with HTTP; Mon, 24 Feb 2014 17:31:00 -0800 (PST) Received: by 10.14.143.76 with HTTP; Mon, 24 Feb 2014 17:31:00 -0800 (PST) In-Reply-To: References: Date: Tue, 25 Feb 2014 09:31:00 +0800 Message-ID: Subject: Re: does AUTO_ACKNOWLEDGE guarantee once and only once semantic for queue consumer? From: Yin Wang To: users@activemq.apache.org Content-Type: multipart/alternative; boundary=089e0163464474cf1d04f3310aee X-Virus-Checked: Checked by ClamAV on apache.org --089e0163464474cf1d04f3310aee Content-Type: text/plain; charset=UTF-8 BTW,AUTO_ACKNOWLEDGE can not guarantee once and only once semantic since the ack is sent async. You can image such a case when your consumer has succeeded in processing a message while the consumer application is crashed before the ack is sent, you will receive that message again if your applications get restarted. Seems what you really want to solve is to distribute real task messages evenly between consumers. As default a consumer has a prefetch to allow broker to push messages to it in batch manner, if a consumer is slow to process message then many pending messages will be accumulated and other consumers may suffer starvation.In this case those real tasks wont get executed in time. You can just use pull mechanism for your consumers so that your consumer can pull real task message from broker one by one. Fast consumers can have a chance to pull more messages than slow consumers. If consumers still can not process real tasks in time, increase consumers or tune performance for consumers. 2014-02-24 19:07 GMT+08:00 Li Li : > I've read the jms specification and questions by google such as > > http://stackoverflow.com/questions/2991412/anyone-know-exactly-which-jms-messages-will-be-redelivered-in-client-acknowledge > . But I still confused about it. > Another question is: how can a consumer tell the broker to > redelevery a message to other consumers(maybe again to this consumer) > e.g. we have some real time tasks and here is code: > class MyConsumer implements MessageListener{ > > public void onMessage(Message msg) { > doPhrase1(); > if(leftTime < avgTime1){ > //Tell broker I can't finish it in time, > //you should redelevery to other consumers > //do some cleanup job > } > doPhrase2(); > if(leftTime < avgTime1){ > //Tell broker I can't finish it in time, > //you should redelevery to other consumers > //do some cleanup job > } > doPhrase3(); > } > --089e0163464474cf1d04f3310aee--