You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Timothy Bish (JIRA)" <ji...@apache.org> on 2010/01/21 20:25:43 UTC
[jira] Commented: (AMQ-2577) Acknowleging a single message actually
acknowleges all messages consumed.
[ https://issues.apache.org/activemq/browse/AMQ-2577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=57044#action_57044 ]
Timothy Bish commented on AMQ-2577:
-----------------------------------
This is actually exactly how CLIENT_ACKNOWLEDGE works.
>From the JMS Specification:
With this acknowledgment mode, the client acknowledges a consumed message by calling the message's acknowledge method. Acknowledging a consumed message acknowledges all messages that the session has consumed.
ActiveMQ has a special acknowledge mode called INDIVIDUAL_ACKNOWLEDGE that can be used if you really want to ack only a single message at a time.
> Acknowleging a single message actually acknowleges all messages consumed.
> -------------------------------------------------------------------------
>
> Key: AMQ-2577
> URL: https://issues.apache.org/activemq/browse/AMQ-2577
> Project: ActiveMQ
> Issue Type: Bug
> Components: JMS client
> Affects Versions: 5.3.0
> Environment: Mac OSX 10.6, CentOS 5 Linux
> Reporter: Brad Willard
>
> If I publish a bunch of messages, and then consume them with a session Session.CLIENT_ACKNOWLEDGE, when I acknowlege the first messages, all messages actually get acknowledged. I'm including some source code that shows the problem.
> This problem can be seen regardless of the Session be transacted or not.
> Thanks,
> Brad
> package bugs;
> import javax.jms.*;
> import java.util.LinkedList;
> import java.net.*;
> import org.apache.activemq.*;
> /**
> *
> * @author bwillard
> */
> public class MessageAcknowledgementBug {
> public static void main(String[] args) {
> try {
> ConnectionFactory factory = new ActiveMQConnectionFactory(URI.create("tcp://localhost:61616"));
> Connection jmsConn = factory.createConnection();
> jmsConn.start();
> Session session = jmsConn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
> Queue queue = session.createQueue("Ack.Bug.Test");
> MessageProducer publisher = session.createProducer(queue);
> TextMessage msg;
> /*
> * Put 50 Messages on Queue
> */
> for (int a = 0; a < 50; a++) {
> msg = session.createTextMessage("" + a);
> publisher.send(msg);
> }
> MessageConsumer reader = session.createConsumer(queue);
> LinkedList<TextMessage> messages = new LinkedList<TextMessage>();
> /*
> * Receive all 50 messages and store in list
> */
> while ((msg = (TextMessage) reader.receiveNoWait()) != null) {
> messages.add(msg);
> }
> /*
> * acknowledge one message, which acknowledges them all as received
> * instead of just the one message
> */
> messages.getFirst().acknowledge();
> reader.close();
> publisher.close();
> jmsConn.stop();
> jmsConn.close();
> } catch (Exception exc) {
> exc.printStackTrace();
> }
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.