You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by To...@t-systems.com on 2021/03/26 10:04:37 UTC

message persists in queue

I'm using the following code to receive a message.
After a successful read I was expecting that the message is remove from the queue?!
But the message was still in the queue.
How can I read a message and remove it?

String result;
             ClientSession session = this.sessionFactory.createSession();
             try {
                    session.start();
                    ClientConsumer consumer = session.createConsumer(ACTIVE_MQ_SMTP_QUEUE);
                    ClientMessage message = consumer.receive();
                    result = message.getDataBuffer().readString();
                    message.acknowledge();
                    session.commit();
             } finally {
                    session.close();
             }

Re: message persists in queue

Posted by Clebert Suconic <cl...@gmail.com>.
create your session with (false, false, false)


this API is sort of internal... we do have some controls on flushes in
ACKs. if you set auto-ack to false, it would flush the acks before you
called commit.

On Fri, Mar 26, 2021 at 6:05 AM <To...@t-systems.com> wrote:
>
> I'm using the following code to receive a message.
> After a successful read I was expecting that the message is remove from the queue?!
> But the message was still in the queue.
> How can I read a message and remove it?
>
> String result;
>              ClientSession session = this.sessionFactory.createSession();
>              try {
>                     session.start();
>                     ClientConsumer consumer = session.createConsumer(ACTIVE_MQ_SMTP_QUEUE);
>                     ClientMessage message = consumer.receive();
>                     result = message.getDataBuffer().readString();
>                     message.acknowledge();
>                     session.commit();
>              } finally {
>                     session.close();
>              }



-- 
Clebert Suconic