From users-return-6125-apmail-qpid-users-archive=qpid.apache.org@qpid.apache.org Thu Apr 12 13:54:24 2012 Return-Path: X-Original-To: apmail-qpid-users-archive@www.apache.org Delivered-To: apmail-qpid-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 6152D9B69 for ; Thu, 12 Apr 2012 13:54:24 +0000 (UTC) Received: (qmail 44554 invoked by uid 500); 12 Apr 2012 13:54:24 -0000 Delivered-To: apmail-qpid-users-archive@qpid.apache.org Received: (qmail 44525 invoked by uid 500); 12 Apr 2012 13:54:24 -0000 Mailing-List: contact users-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@qpid.apache.org Delivered-To: mailing list users@qpid.apache.org Received: (qmail 44517 invoked by uid 99); 12 Apr 2012 13:54:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Apr 2012 13:54:24 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of pmoravec@redhat.com designates 209.132.183.25 as permitted sender) Received: from [209.132.183.25] (HELO mx4-phx2.redhat.com) (209.132.183.25) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Apr 2012 13:54:16 +0000 Received: from mail02.corp.redhat.com (zmail02.collab.prod.int.phx2.redhat.com [10.5.5.42]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q3CDrqd4024734 for ; Thu, 12 Apr 2012 09:53:52 -0400 Date: Thu, 12 Apr 2012 09:53:52 -0400 (EDT) From: Pavel Moravec To: users@qpid.apache.org Subject: Selective message acknowledgment in Java client (and C++ broker)? Message-ID: <4f88a586-0276-4fdc-a191-416b58d00c81@zmail02.collab.prod.int.phx2.redhat.com> In-Reply-To: <532c36b6-a6c4-4905-b3fd-d39ec31839a4@zmail02.collab.prod.int.phx2.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-Originating-IP: [10.36.5.38] X-Mailer: Zimbra 7.1.2_GA_3268 (ZimbraWebClient - FF3.0 (Linux)/7.1.2_GA_3268) Hello, having Java client and C++ broker, I want to implement selective consumption of messages from a queue (something like JMS message selectors in Java broker). I.e.: 1) Having CLIENT_ACKNOWLEDGE mode, 2) In a loop through all messages of the queue: a) receive a message b) decide if to consume or not c) if so, acknowledge it, if not so, ignore it 3) Close the session to retrieve the unacknowledged messages back to the queue. However, I see no way of doing so. Method Message.acknowledge(); is not suitable as it acknowledges also all previous messages, following JMS specification. Using method AbstractJMSMessage.acknowledgeThis(), I got the same results. Though the method name would suggest, it shall acknowledge just this message, no else. But checking source code: public void acknowledgeThis() throws JMSException { // the JMS 1.1 spec says in section 3.6 that calls to acknowledge are ignored when client acknowledge // is not specified. In our case, we only set the session field where client acknowledge mode is specified. if (_session != null && _session.getAcknowledgeMode() == Session.CLIENT_ACKNOWLEDGE) { if (_session.getAMQConnection().isClosed()) { throw new javax.jms.IllegalStateException("Connection is already closed"); } // we set multiple to true here since acknowledgment implies acknowledge of all previous messages // received on the session _session.acknowledgeMessage(_deliveryTag, true); } } See the latest comment - it acknowledges all previous messages on purpose. Having the last command: _session.acknowledgeMessage(_deliveryTag, false); only this message will be acknowledged, no else. Is there some reason for this behavior? If so, how can I achieve a real single message acknowledgment? Thanks in advance for your thoughs. Kind regards, Pavel --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org For additional commands, e-mail: users-help@qpid.apache.org