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 3315D105C3 for ; Tue, 25 Feb 2014 11:42:07 +0000 (UTC) Received: (qmail 60835 invoked by uid 500); 25 Feb 2014 11:42:06 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 60605 invoked by uid 500); 25 Feb 2014 11:42:04 -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 60588 invoked by uid 99); 25 Feb 2014 11:42:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Feb 2014 11:42:03 +0000 X-ASF-Spam-Status: No, hits=0.6 required=5.0 tests=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.169 as permitted sender) Received: from [209.85.213.169] (HELO mail-ig0-f169.google.com) (209.85.213.169) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Feb 2014 11:41:59 +0000 Received: by mail-ig0-f169.google.com with SMTP id h18so7273251igc.0 for ; Tue, 25 Feb 2014 03:41:38 -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=qXIGxVmXG85b5JGjd7NZUGk9UqB0AyLGUOcc4jVzjSw=; b=dDMDoEjRIIb1MWRWQM2psh8G1iRpDPRvYLMy0gAjNkHGaHSJN2Zetb2QYuTWf/SMVR zIus9AxEgANdBU12xJD03DQa9GkEmFypTcSBB7jkRXeDzSExV2NVfLwiaPw3MnXat0TO j1qTKfC7UiqmVLjrkzwYI6AuSUGTbQdQZ4v+BiPPU4niizPH1KLSSXUHYcBqnKjfNXCv k8hlE4mmRUmmwctkoMLkhLWLE+15QU6xjvffI2xqBKwcaVqQB+RSK4BiyajTz1lyHc/p Jn3368xXPGokkVYJP0NT+wvVPGKhZfs3KvpmEB1byM+xBnFT7+ZvimXgLO9xfPSIpcJV CP9A== MIME-Version: 1.0 X-Received: by 10.50.33.11 with SMTP id n11mr19259501igi.0.1393328498507; Tue, 25 Feb 2014 03:41:38 -0800 (PST) Received: by 10.64.225.205 with HTTP; Tue, 25 Feb 2014 03:41:38 -0800 (PST) In-Reply-To: References: <1393294230808-4678338.post@n4.nabble.com> Date: Tue, 25 Feb 2014 11:41:38 +0000 Message-ID: Subject: Re: does AUTO_ACKNOWLEDGE guarantee once and only once semantic for queue consumer? From: Gary Tully To: "users@activemq.apache.org" Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org in the absense of xa, I think we can do better with the redeliveryflag such that it can be used as a reliable indication of duplicate dispatch. In that way, an application can avoid doing duplicate checks when the flag is not set, even after a broker failure. It will come as a cost, but it opens up a new class of usecases. see: https://issues.apache.org/jira/browse/AMQ-5068 On 25 February 2014 02:54, David Jencks wrote: > Using activemq with a jta transaction manager and using the appropriate xa interfaces (such as through the resource adapter) will guarantee that a message is delivered exactly once. Many people prefer to use idempotent messages to avoid the xa overhead. > > david jencks > > > On Feb 24, 2014, at 6:45 PM, Li Li wrote: > >> thanks. Since JMS can't guarantee only once, it's the client's >> responsibility to make things correct. it should either using >> idempotent processing(running a task twice is no harm) or using other >> tools(such as zookeeper or database to make data consistent). So I >> think there is still many dirty work to do in some strict environment. >> is there any practical usage of JMS(activemq) in real world in >> industry such as financial or e-commerce? >> on the other hand, does JMS guarantee at least once delivery? What's >> the redelevery mean? >> as said in https://activemq.apache.org/message-redelivery-and-dlq-handling.html >> >> Messages are redelivered to a client when any of the following occurs: >> >> A transacted session is used and rollback() is called. >> A transacted session is closed before commit is called. >> A session is using CLIENT_ACKNOWLEDGE and Session.recover() is called. >> >> I notice that when a client crashed in the onMessage method and >> restart. the message will be dispatched to another consumer with >> getJMSRedelivered()==true. it this message a redelivered one? >> also, if the consumer is very slow(maybe hang for an hour,stay in >> onMessage so it's not acknowledged) and the message has a short TTL, >> will it be redelivered to another consumer or to dead letter queue? >> >> >> On Tue, Feb 25, 2014 at 10:10 AM, artnaseef wrote: >>> The use-case sounds like one that needs more than just ActiveMQ to solve >>> well. >>> >>> In JMS, redeliveries of messages must be expected and handled by >>> applications. There are cases where the JMS redelivered property is set, >>> but the application may not have touched the message ever before - such as >>> when the message is dispatched in the prefetch for the client and the client >>> terminates without getting to the message. Even with prefetch 0, the same >>> problem can happen. >>> >>> The JMS redelivered property is a hint that lets an application know that >>> there is a risk the message was actually handled before. >>> >>> My preference is to think of JMS guarantees as a great way to simplify the >>> normal processing path in an application as it eliminates the need to >>> consider how messages can get lost in transit and protecting against the >>> same. However, it's not intended to be a way to signal to the broker to try >>> a different consumer. And it doesn't eliminate considerations under error >>> cases - such as a consumer terminating in the middle of processing the >>> message. >>> >>> On the practical front, rejecting a message so that the broker resends it >>> will introduce notable delay. It may also result in the message being >>> redelivered to the same client. Also, I would need to check -- there may >>> also be a TTL issue in which case the message could end up stuck on the >>> broker. >>> >>> In your use-case, I would consider ActiveMQ as an underlying component to a >>> complete solution. Perhaps using camel with a server that routes tasks to >>> task engines. Also, I recommend considering a proactive approach to the >>> problem. Waiting until the task reaches a task engine to have it rejected >>> may lead to problems. For example, what if the fastest task engine is too >>> slow for the task? The task will starve. Using feedback from the task >>> engines to the routing engine, the routing engine can decide the best task >>> engine using heuristics (such as best fit - not always the fastest engine). >>> >>> To get the guarantee a task only ever executes once, you'll need a reliable >>> lock/state engine. Zookeeper comes to mind. Note that many applications >>> prefer to use an idempotent processing model so that duplicate processing >>> causes no problems. >>> >>> Hope this helps. >>> >>> >>> >>> -- >>> View this message in context: http://activemq.2283324.n4.nabble.com/does-AUTO-ACKNOWLEDGE-guarantee-once-and-only-once-semantic-for-queue-consumer-tp4678300p4678338.html >>> Sent from the ActiveMQ - User mailing list archive at Nabble.com. > -- http://redhat.com http://blog.garytully.com