You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by John Lilley <jo...@redpointglobal.com.INVALID> on 2022/09/29 22:00:48 UTC

Processing only one message

We have an application that should read a single message from a queue (a “job” queue) and then stop processing more messages.  Think of it as a “batch request”.  This is entirely using the JMS driver. Is there a good pattern for this?

Under ActiveMQ 5, I call consumer.close(), session.close() from onMessage() and that works fine.  However, session.close() is not allowed under Artemis (and maybe it was always wrong).

I’ve tried calling only consumer.close(), and leave the session open.  But the message is not ACked.  Explicitly calling message.acknowledge() doesn’t work either, because it gets to >>> and individualAck is false:

public void acknowledge() throws JMSException {
   if (session != null) {
      try {
         if (session.isClosed()) {
            throw ActiveMQClientMessageBundle.BUNDLE.sessionClosed();
         }
>>>         if (individualAck) {
            message.individualAcknowledge();
         }

Going back to the original question, what is the recommended pattern for this?

Thanks
john


[rg] <https://www.redpointglobal.com/>

John Lilley

Chief Architect, Redpoint Global Inc.

888 Worcester Street, Suite 200 Wellesley, MA 02482

M: +1 7209385761<tel:+1%207209385761> | john.lilley@redpointglobal.com<ma...@redpointglobal.com>

PLEASE NOTE: This e-mail from Redpoint Global Inc. (“Redpoint”) is confidential and is intended solely for the use of the individual(s) to whom it is addressed. If you believe you received this e-mail in error, please notify the sender immediately, delete the e-mail from your computer and do not copy, print or disclose it to anyone else. If you properly received this e-mail as a customer, partner or vendor of Redpoint, you should maintain its contents in confidence subject to the terms and conditions of your agreement(s) with Redpoint.

Re: Processing only one message

Posted by Robbie Gemmell <ro...@gmail.com>.
Possibly, it's not something I've tried with the Artemis client, I was just
mainly pointing out JMS says acknowledge() does nothing if you aren't using
the click-ack mode its for. Identifying if there really is a bug with the
close-in-auto-ack-listener and perhaps fixing it might be another route.

On Fri, 30 Sept 2022 at 14:51, John Lilley
<jo...@redpointglobal.com.invalid> wrote:

> Robbie,
>
>
>
> I am using auto-ack mode generally.  So perhaps one solution is to make
> this consumer manual-ACK instead?  I’ll try that.  If it works it will be
> easier than changing our code to use consumer.receive().
>
> Thanks
>
> john
>
>
>
>
> [image: rg] <https://www.redpointglobal.com/>
>
> John Lilley
>
> Chief Architect, Redpoint Global Inc.
>
> 888 Worcester Street, Suite 200 Wellesley, MA 02482
>
> *M: *+1 7209385761 <+1%207209385761> | john.lilley@redpointglobal.com
>
> *From:* Robbie Gemmell <ro...@gmail.com>
> *Sent:* Friday, September 30, 2022 6:49 AM
> *To:* users@activemq.apache.org
> *Subject:* Re: Processing only one message
>
>
>
> **** [Caution] This email is from an external source. Please use caution
> responding, opening attachments or clicking embedded links. ****
>
>
>
> If you only want to get a single message it might make more sense to use
> [possibly non-prefetching if really only wanting 1 message]
> consumer.receive(..) style calls rather than a MessageListener.
>
>
>
> Opening and closing a consumer and session per-message is quite
> inefficient. Are you also closing the connection after each message, or
> does the application reuse it to create a new session and consumer+listener
> for future work? If the latter it definitely makes sense to just leave the
> consumer open and reuse it to get each message in turn. Depending on the
> number of consumers and whether they are competing, it may even make sense
> to actually use prefetching at that point too.
>
>
>
> The reason the session.close() throws is that the original JMS 1.1 spec
> described it such that the client should effectively deadlock itself in
> that situation. JMS 2 changed the spec description to say it could throw,
> as many impls did, or could close, but since it isn't portable as there is
> different behaviour, doing so should be avoided.
>
>
>
> That said, calling consumer.close() should work, its possible there is a
> bug there, depending on what you are doing overall.
>
>
>
> You dont say what ack mode you are using. The message.acknowledge() method
> is to be ignored for anything but use of the CLIENT_ACK session mode (or
> the client has an individual-ack extension/non-JMS ack mode too), at which
> point note that it acks all prior messages received on the session, not
> just the message it is called on (unless using the extension individual ack
> mode is being used, when will only do the message its called on). Though
> those would be effectively the same if you only get 1 message at a time.
>
>
>
> On Thu, 29 Sept 2022 at 23:01, John Lilley <
> john.lilley@redpointglobal.com.invalid> wrote:
>
> We have an application that should read a single message from a queue (a
> “job” queue) and then stop processing more messages.  Think of it as a
> “batch request”.  This is entirely using the JMS driver. Is there a good
> pattern for this?
>
>
>
> Under ActiveMQ 5, I call consumer.close(), session.close() from
> onMessage() and that works fine.  However, session.close() is not allowed
> under Artemis (and maybe it was always wrong).
>
>
>
> I’ve tried calling only consumer.close(), and leave the session open.  But
> the message is not ACked.  Explicitly calling message.acknowledge() doesn’t
> work either, because it gets to >>> and individualAck is false:
>
>
>
> *public void *acknowledge() *throws *JMSException {
>    *if *(*session *!= *null*) {
>       *try *{
>          *if *(*session*.isClosed()) {
>             *throw *ActiveMQClientMessageBundle.*BUNDLE*.sessionClosed();
>          }
> >>>         *if *(*individualAck*) {
>             *message*.individualAcknowledge();
>          }
>
>
>
> Going back to the original question, what is the recommended pattern for
> this?
>
>
>
> Thanks
>
> john
>
>
>
> [image: rg]
> <https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fwww.redpointglobal.com%2f&c=E,1,0ZDntuxk_EAfCKQLGnMBAyrhnrNZ9KcKhTj_3e7rK3jtFtz3NjCpKV2H_AkznQUD94jByfxPdpOf109Y27PGyw-62M1Pwd77UKKfeOg0BsADuKvpDZFFjEQr&typo=1>
>
> *John Lilley *
>
> *Chief Architect, Redpoint Global Inc. *
>
> 888 Worcester Street, Suite 200 Wellesley, MA 02482
>
> *M: *+1 7209385761 <+1%207209385761> | john.lilley@redpointglobal.com
>
>
> PLEASE NOTE: This e-mail from Redpoint Global Inc. (“Redpoint”) is
> confidential and is intended solely for the use of the individual(s) to
> whom it is addressed. If you believe you received this e-mail in error,
> please notify the sender immediately, delete the e-mail from your computer
> and do not copy, print or disclose it to anyone else. If you properly
> received this e-mail as a customer, partner or vendor of Redpoint, you
> should maintain its contents in confidence subject to the terms and
> conditions of your agreement(s) with Redpoint.
>
>
> PLEASE NOTE: This e-mail from Redpoint Global Inc. (“Redpoint”) is
> confidential and is intended solely for the use of the individual(s) to
> whom it is addressed. If you believe you received this e-mail in error,
> please notify the sender immediately, delete the e-mail from your computer
> and do not copy, print or disclose it to anyone else. If you properly
> received this e-mail as a customer, partner or vendor of Redpoint, you
> should maintain its contents in confidence subject to the terms and
> conditions of your agreement(s) with Redpoint.
>

RE: Processing only one message

Posted by John Lilley <jo...@redpointglobal.com.INVALID>.
Robbie,

I am using auto-ack mode generally.  So perhaps one solution is to make this consumer manual-ACK instead?  I’ll try that.  If it works it will be easier than changing our code to use consumer.receive().
Thanks
john




[rg] <https://www.redpointglobal.com/>

John Lilley

Chief Architect, Redpoint Global Inc.

888 Worcester Street, Suite 200 Wellesley, MA 02482

M: +1 7209385761<tel:+1%207209385761> | john.lilley@redpointglobal.com<ma...@redpointglobal.com>
From: Robbie Gemmell <ro...@gmail.com>
Sent: Friday, September 30, 2022 6:49 AM
To: users@activemq.apache.org
Subject: Re: Processing only one message

*** [Caution] This email is from an external source. Please use caution responding, opening attachments or clicking embedded links. ***

If you only want to get a single message it might make more sense to use [possibly non-prefetching if really only wanting 1 message] consumer.receive(..) style calls rather than a MessageListener.

Opening and closing a consumer and session per-message is quite inefficient. Are you also closing the connection after each message, or does the application reuse it to create a new session and consumer+listener for future work? If the latter it definitely makes sense to just leave the consumer open and reuse it to get each message in turn. Depending on the number of consumers and whether they are competing, it may even make sense to actually use prefetching at that point too.

The reason the session.close() throws is that the original JMS 1.1 spec described it such that the client should effectively deadlock itself in that situation. JMS 2 changed the spec description to say it could throw, as many impls did, or could close, but since it isn't portable as there is different behaviour, doing so should be avoided.

That said, calling consumer.close() should work, its possible there is a bug there, depending on what you are doing overall.

You dont say what ack mode you are using. The message.acknowledge() method is to be ignored for anything but use of the CLIENT_ACK session mode (or the client has an individual-ack extension/non-JMS ack mode too), at which point note that it acks all prior messages received on the session, not just the message it is called on (unless using the extension individual ack mode is being used, when will only do the message its called on). Though those would be effectively the same if you only get 1 message at a time.

On Thu, 29 Sept 2022 at 23:01, John Lilley <jo...@redpointglobal.com.invalid>> wrote:
We have an application that should read a single message from a queue (a “job” queue) and then stop processing more messages.  Think of it as a “batch request”.  This is entirely using the JMS driver. Is there a good pattern for this?

Under ActiveMQ 5, I call consumer.close(), session.close() from onMessage() and that works fine.  However, session.close() is not allowed under Artemis (and maybe it was always wrong).

I’ve tried calling only consumer.close(), and leave the session open.  But the message is not ACked.  Explicitly calling message.acknowledge() doesn’t work either, because it gets to >>> and individualAck is false:

public void acknowledge() throws JMSException {
   if (session != null) {
      try {
         if (session.isClosed()) {
            throw ActiveMQClientMessageBundle.BUNDLE.sessionClosed();
         }
>>>         if (individualAck) {
            message.individualAcknowledge();
         }

Going back to the original question, what is the recommended pattern for this?

Thanks
john


[rg]<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fwww.redpointglobal.com%2f&c=E,1,0ZDntuxk_EAfCKQLGnMBAyrhnrNZ9KcKhTj_3e7rK3jtFtz3NjCpKV2H_AkznQUD94jByfxPdpOf109Y27PGyw-62M1Pwd77UKKfeOg0BsADuKvpDZFFjEQr&typo=1>

John Lilley

Chief Architect, Redpoint Global Inc.

888 Worcester Street, Suite 200 Wellesley, MA 02482

M: +1 7209385761<tel:+1%207209385761> | john.lilley@redpointglobal.com<ma...@redpointglobal.com>

PLEASE NOTE: This e-mail from Redpoint Global Inc. (“Redpoint”) is confidential and is intended solely for the use of the individual(s) to whom it is addressed. If you believe you received this e-mail in error, please notify the sender immediately, delete the e-mail from your computer and do not copy, print or disclose it to anyone else. If you properly received this e-mail as a customer, partner or vendor of Redpoint, you should maintain its contents in confidence subject to the terms and conditions of your agreement(s) with Redpoint.

PLEASE NOTE: This e-mail from Redpoint Global Inc. (“Redpoint”) is confidential and is intended solely for the use of the individual(s) to whom it is addressed. If you believe you received this e-mail in error, please notify the sender immediately, delete the e-mail from your computer and do not copy, print or disclose it to anyone else. If you properly received this e-mail as a customer, partner or vendor of Redpoint, you should maintain its contents in confidence subject to the terms and conditions of your agreement(s) with Redpoint.

Re: Processing only one message

Posted by Robbie Gemmell <ro...@gmail.com>.
If you only want to get a single message it might make more sense to use
[possibly non-prefetching if really only wanting 1 message]
consumer.receive(..) style calls rather than a MessageListener.

Opening and closing a consumer and session per-message is quite
inefficient. Are you also closing the connection after each message, or
does the application reuse it to create a new session and consumer+listener
for future work? If the latter it definitely makes sense to just leave the
consumer open and reuse it to get each message in turn. Depending on the
number of consumers and whether they are competing, it may even make sense
to actually use prefetching at that point too.

The reason the session.close() throws is that the original JMS 1.1 spec
described it such that the client should effectively deadlock itself in
that situation. JMS 2 changed the spec description to say it could throw,
as many impls did, or could close, but since it isn't portable as there is
different behaviour, doing so should be avoided.

That said, calling consumer.close() should work, its possible there is a
bug there, depending on what you are doing overall.

You dont say what ack mode you are using. The message.acknowledge() method
is to be ignored for anything but use of the CLIENT_ACK session mode (or
the client has an individual-ack extension/non-JMS ack mode too), at which
point note that it acks all prior messages received on the session, not
just the message it is called on (unless using the extension individual ack
mode is being used, when will only do the message its called on). Though
those would be effectively the same if you only get 1 message at a time.

On Thu, 29 Sept 2022 at 23:01, John Lilley
<jo...@redpointglobal.com.invalid> wrote:

> We have an application that should read a single message from a queue (a
> “job” queue) and then stop processing more messages.  Think of it as a
> “batch request”.  This is entirely using the JMS driver. Is there a good
> pattern for this?
>
>
>
> Under ActiveMQ 5, I call consumer.close(), session.close() from
> onMessage() and that works fine.  However, session.close() is not allowed
> under Artemis (and maybe it was always wrong).
>
>
>
> I’ve tried calling only consumer.close(), and leave the session open.  But
> the message is not ACked.  Explicitly calling message.acknowledge() doesn’t
> work either, because it gets to >>> and individualAck is false:
>
>
>
> *public void *acknowledge() *throws *JMSException {
>    *if *(*session *!= *null*) {
>       *try *{
>          *if *(*session*.isClosed()) {
>             *throw *ActiveMQClientMessageBundle.*BUNDLE*.sessionClosed();
>          }
> >>>         *if *(*individualAck*) {
>             *message*.individualAcknowledge();
>          }
>
>
>
> Going back to the original question, what is the recommended pattern for
> this?
>
>
>
> Thanks
>
> john
>
> [image: rg] <https://www.redpointglobal.com/>
>
> John Lilley
>
> Chief Architect, Redpoint Global Inc.
>
> 888 Worcester Street, Suite 200 Wellesley, MA 02482
>
> *M: *+1 7209385761 <+1%207209385761> | john.lilley@redpointglobal.com
>
> PLEASE NOTE: This e-mail from Redpoint Global Inc. (“Redpoint”) is
> confidential and is intended solely for the use of the individual(s) to
> whom it is addressed. If you believe you received this e-mail in error,
> please notify the sender immediately, delete the e-mail from your computer
> and do not copy, print or disclose it to anyone else. If you properly
> received this e-mail as a customer, partner or vendor of Redpoint, you
> should maintain its contents in confidence subject to the terms and
> conditions of your agreement(s) with Redpoint.
>

Re: Processing only one message

Posted by Stephen Baker <st...@rmssoftwareinc.com>.
I traced this code quite recently because we needed to switch to using it for one of our clients and also would have preferred specifying it on the consumer. ClientSession in the core API exposes the windowSize as a parameter for creating consumers, but the JMS shim ActiveMQSession does not.

The value cannot be changed on an existing session in either the Core or JMS APIs, but the value in the session is only used as the default when creating consumers.

The other option is to specify the <default-consumer-window-size> in <address-settings> on the server to 0.

Note that there’s a small / nit bug. If the Client requests a consumerWindowSize of exactly 1M and the server default value is set to something other than 1M, the server’s value will be used instead of the clients.

That’s in ActiveMQSessionContext:
      final int consumerWindowSize = windowSize == ActiveMQClient.DEFAULT_CONSUMER_WINDOW_SIZE ? this.getDefaultConsumerWindowSize(queueInfo) : windowSize;

I haven’t brought it up before because I’m not sure it’s worth fixing.

From: Clebert Suconic <cl...@gmail.com>
Date: Friday, September 30, 2022 at 9:02 PM
To: users@activemq.apache.org <us...@activemq.apache.org>
Subject: Re: Processing only one message
Internal property on the consumer I meant.

On Fri, Sep 30, 2022 at 9:01 PM Clebert Suconic <cl...@gmail.com>> wrote:

I don’t think you can do that. That’s a property for the session afaik.  If you see an internal property with that name be careful as I’m not aware of any tests.


On Fri, Sep 30, 2022 at 4:16 PM John Lilley <jo...@redpointglobal.com.invalid> wrote:
Clebert,

Thank for the reply!  I can see how to see this for the connection by adding this to the URL
?consumerWindowSize=0
https://activemq.apache.org/components/artemis/documentation/1.1.0/flow-control.html

I can also call setConsumerWindowSize(0) on the connection factory.

Can I set this explicitly on a consumer instance after it is created?

john



[rg]<https://www.redpointglobal.com/>

John Lilley

Chief Architect, Redpoint Global Inc.

888 Worcester Street, Suite 200 Wellesley, MA 02482<https://www.google.com/maps/search/888+Worcester+Street,+Suite+200+Wellesley,+MA+02482?entry=gmail&source=g>

M: +1 7209385761<tel:+1%207209385761> | john.lilley@redpointglobal.com<ma...@redpointglobal.com>
From: Clebert Suconic <cl...@gmail.com>>
Sent: Friday, September 30, 2022 3:02 AM
To: users@activemq.apache.org<ma...@activemq.apache.org>
Subject: Re: Processing only one message

*** [Caution] This email is from an external source. Please use caution responding, opening attachments or clicking embedded links. ***

Look at slow consumers.   Set consumer window size to 0 on this consumer.

On Thu, Sep 29, 2022 at 6:01 PM John Lilley <jo...@redpointglobal.com.invalid>> wrote:
We have an application that should read a single message from a queue (a “job” queue) and then stop processing more messages.  Think of it as a “batch request”.  This is entirely using the JMS driver. Is there a good pattern for this?

Under ActiveMQ 5, I call consumer.close(), session.close() from onMessage() and that works fine.  However, session.close() is not allowed under Artemis (and maybe it was always wrong).

I’ve tried calling only consumer.close(), and leave the session open.  But the message is not ACked.  Explicitly calling message.acknowledge() doesn’t work either, because it gets to >>> and individualAck is false:

public void acknowledge() throws JMSException {
   if (session != null) {
      try {
         if (session.isClosed()) {
            throw ActiveMQClientMessageBundle.BUNDLE.sessionClosed();
         }
>>>         if (individualAck) {
            message.individualAcknowledge();
         }

Going back to the original question, what is the recommended pattern for this?

Thanks
john


Error! Filename not specified.<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fwww.redpointglobal.com%2f&c=E,1,woI5c78_8f-DCJwnBAd2SB8ZQhLpa0H91b89ArK-kwPX0ToGxJQJmAWCo4pKKXorliMxDRxv9bVPLRhLdu50I9WBzrjdu8_-3xSL4nhKhbgAxC-hndfqanIBQp4,&typo=1>

John Lilley

Chief Architect, Redpoint Global Inc.

888 Worcester Street, Suite 200 Wellesley, MA 02482<https://www.google.com/maps/search/888+Worcester+Street,+Suite+200+Wellesley,+MA+02482?entry=gmail&source=g>

M: +1 7209385761<tel:+1%207209385761> | john.lilley@redpointglobal.com<ma...@redpointglobal.com>

PLEASE NOTE: This e-mail from Redpoint Global Inc. (“Redpoint”) is confidential and is intended solely for the use of the individual(s) to whom it is addressed. If you believe you received this e-mail in error, please notify the sender immediately, delete the e-mail from your computer and do not copy, print or disclose it to anyone else. If you properly received this e-mail as a customer, partner or vendor of Redpoint, you should maintain its contents in confidence subject to the terms and conditions of your agreement(s) with Redpoint.
--
Clebert Suconic

PLEASE NOTE: This e-mail from Redpoint Global Inc. (“Redpoint”) is confidential and is intended solely for the use of the individual(s) to whom it is addressed. If you believe you received this e-mail in error, please notify the sender immediately, delete the e-mail from your computer and do not copy, print or disclose it to anyone else. If you properly received this e-mail as a customer, partner or vendor of Redpoint, you should maintain its contents in confidence subject to the terms and conditions of your agreement(s) with Redpoint.
--
Clebert Suconic
--
Clebert Suconic

[EXTERNAL]: This email originated from outside of Rave Mobile Safety. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Re: Processing only one message

Posted by Clebert Suconic <cl...@gmail.com>.
Internal property on the consumer I meant.

On Fri, Sep 30, 2022 at 9:01 PM Clebert Suconic <cl...@gmail.com>
wrote:

>
> I don’t think you can do that. That’s a property for the session afaik.
> If you see an internal property with that name be careful as I’m not aware
> of any tests.
>
>
> On Fri, Sep 30, 2022 at 4:16 PM John Lilley
> <jo...@redpointglobal.com.invalid> wrote:
>
>> Clebert,
>>
>>
>>
>> Thank for the reply!  I can see how to see this for the connection by
>> adding this to the URL
>>
>> ?consumerWindowSize=0
>>
>>
>> https://activemq.apache.org/components/artemis/documentation/1.1.0/flow-control.html
>>
>>
>>
>> I can also call setConsumerWindowSize(0) on the connection factory.
>>
>>
>>
>> Can I set this explicitly on a consumer instance after it is created?
>>
>>
>>
>> john
>>
>>
>>
>>
>> [image: rg] <https://www.redpointglobal.com/>
>>
>> John Lilley
>>
>> Chief Architect, Redpoint Global Inc.
>>
>> 888 Worcester Street, Suite 200 Wellesley, MA 02482
>> <https://www.google.com/maps/search/888+Worcester+Street,+Suite+200+Wellesley,+MA+02482?entry=gmail&source=g>
>>
>> *M: *+1 7209385761 <+1%207209385761> | john.lilley@redpointglobal.com
>>
>> *From:* Clebert Suconic <cl...@gmail.com>
>> *Sent:* Friday, September 30, 2022 3:02 AM
>> *To:* users@activemq.apache.org
>> *Subject:* Re: Processing only one message
>>
>>
>>
>> **** [Caution] This email is from an external source. Please use caution
>> responding, opening attachments or clicking embedded links. ****
>>
>>
>>
>> Look at slow consumers.   Set consumer window size to 0 on this consumer.
>>
>>
>>
>> On Thu, Sep 29, 2022 at 6:01 PM John Lilley <
>> john.lilley@redpointglobal.com.invalid> wrote:
>>
>> We have an application that should read a single message from a queue (a
>> “job” queue) and then stop processing more messages.  Think of it as a
>> “batch request”.  This is entirely using the JMS driver. Is there a good
>> pattern for this?
>>
>>
>>
>> Under ActiveMQ 5, I call consumer.close(), session.close() from
>> onMessage() and that works fine.  However, session.close() is not allowed
>> under Artemis (and maybe it was always wrong).
>>
>>
>>
>> I’ve tried calling only consumer.close(), and leave the session open.
>> But the message is not ACked.  Explicitly calling message.acknowledge()
>> doesn’t work either, because it gets to >>> and individualAck is false:
>>
>>
>>
>> *public void *acknowledge() *throws *JMSException {
>>    *if *(*session *!= *null*) {
>>       *try *{
>>          *if *(*session*.isClosed()) {
>>             *throw *ActiveMQClientMessageBundle.*BUNDLE*.sessionClosed();
>>          }
>> >>>         *if *(*individualAck*) {
>>             *message*.individualAcknowledge();
>>          }
>>
>>
>>
>> Going back to the original question, what is the recommended pattern for
>> this?
>>
>>
>>
>> Thanks
>>
>> john
>>
>>
>>
>> [image: rg]
>> <https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fwww.redpointglobal.com%2f&c=E,1,woI5c78_8f-DCJwnBAd2SB8ZQhLpa0H91b89ArK-kwPX0ToGxJQJmAWCo4pKKXorliMxDRxv9bVPLRhLdu50I9WBzrjdu8_-3xSL4nhKhbgAxC-hndfqanIBQp4,&typo=1>
>>
>> *John Lilley *
>>
>> *Chief Architect, Redpoint Global Inc. *
>>
>> 888 Worcester Street, Suite 200 Wellesley, MA 02482
>> <https://www.google.com/maps/search/888+Worcester+Street,+Suite+200+Wellesley,+MA+02482?entry=gmail&source=g>
>>
>> *M: *+1 7209385761 <+1%207209385761> | john.lilley@redpointglobal.com
>>
>>
>> PLEASE NOTE: This e-mail from Redpoint Global Inc. (“Redpoint”) is
>> confidential and is intended solely for the use of the individual(s) to
>> whom it is addressed. If you believe you received this e-mail in error,
>> please notify the sender immediately, delete the e-mail from your computer
>> and do not copy, print or disclose it to anyone else. If you properly
>> received this e-mail as a customer, partner or vendor of Redpoint, you
>> should maintain its contents in confidence subject to the terms and
>> conditions of your agreement(s) with Redpoint.
>>
>> --
>>
>> Clebert Suconic
>>
>> PLEASE NOTE: This e-mail from Redpoint Global Inc. (“Redpoint”) is
>> confidential and is intended solely for the use of the individual(s) to
>> whom it is addressed. If you believe you received this e-mail in error,
>> please notify the sender immediately, delete the e-mail from your computer
>> and do not copy, print or disclose it to anyone else. If you properly
>> received this e-mail as a customer, partner or vendor of Redpoint, you
>> should maintain its contents in confidence subject to the terms and
>> conditions of your agreement(s) with Redpoint.
>>
> --
> Clebert Suconic
>
-- 
Clebert Suconic

Re: Processing only one message

Posted by Clebert Suconic <cl...@gmail.com>.
I don’t think you can do that. That’s a property for the session afaik.  If
you see an internal property with that name be careful as I’m not aware of
any tests.


On Fri, Sep 30, 2022 at 4:16 PM John Lilley
<jo...@redpointglobal.com.invalid> wrote:

> Clebert,
>
>
>
> Thank for the reply!  I can see how to see this for the connection by
> adding this to the URL
>
> ?consumerWindowSize=0
>
>
> https://activemq.apache.org/components/artemis/documentation/1.1.0/flow-control.html
>
>
>
> I can also call setConsumerWindowSize(0) on the connection factory.
>
>
>
> Can I set this explicitly on a consumer instance after it is created?
>
>
>
> john
>
>
>
>
> [image: rg] <https://www.redpointglobal.com/>
>
> John Lilley
>
> Chief Architect, Redpoint Global Inc.
>
> 888 Worcester Street, Suite 200 Wellesley, MA 02482
> <https://www.google.com/maps/search/888+Worcester+Street,+Suite+200+Wellesley,+MA+02482?entry=gmail&source=g>
>
> *M: *+1 7209385761 <+1%207209385761> | john.lilley@redpointglobal.com
>
> *From:* Clebert Suconic <cl...@gmail.com>
> *Sent:* Friday, September 30, 2022 3:02 AM
> *To:* users@activemq.apache.org
> *Subject:* Re: Processing only one message
>
>
>
> **** [Caution] This email is from an external source. Please use caution
> responding, opening attachments or clicking embedded links. ****
>
>
>
> Look at slow consumers.   Set consumer window size to 0 on this consumer.
>
>
>
> On Thu, Sep 29, 2022 at 6:01 PM John Lilley <
> john.lilley@redpointglobal.com.invalid> wrote:
>
> We have an application that should read a single message from a queue (a
> “job” queue) and then stop processing more messages.  Think of it as a
> “batch request”.  This is entirely using the JMS driver. Is there a good
> pattern for this?
>
>
>
> Under ActiveMQ 5, I call consumer.close(), session.close() from
> onMessage() and that works fine.  However, session.close() is not allowed
> under Artemis (and maybe it was always wrong).
>
>
>
> I’ve tried calling only consumer.close(), and leave the session open.  But
> the message is not ACked.  Explicitly calling message.acknowledge() doesn’t
> work either, because it gets to >>> and individualAck is false:
>
>
>
> *public void *acknowledge() *throws *JMSException {
>    *if *(*session *!= *null*) {
>       *try *{
>          *if *(*session*.isClosed()) {
>             *throw *ActiveMQClientMessageBundle.*BUNDLE*.sessionClosed();
>          }
> >>>         *if *(*individualAck*) {
>             *message*.individualAcknowledge();
>          }
>
>
>
> Going back to the original question, what is the recommended pattern for
> this?
>
>
>
> Thanks
>
> john
>
>
>
> [image: rg]
> <https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fwww.redpointglobal.com%2f&c=E,1,woI5c78_8f-DCJwnBAd2SB8ZQhLpa0H91b89ArK-kwPX0ToGxJQJmAWCo4pKKXorliMxDRxv9bVPLRhLdu50I9WBzrjdu8_-3xSL4nhKhbgAxC-hndfqanIBQp4,&typo=1>
>
> *John Lilley *
>
> *Chief Architect, Redpoint Global Inc. *
>
> 888 Worcester Street, Suite 200 Wellesley, MA 02482
> <https://www.google.com/maps/search/888+Worcester+Street,+Suite+200+Wellesley,+MA+02482?entry=gmail&source=g>
>
> *M: *+1 7209385761 <+1%207209385761> | john.lilley@redpointglobal.com
>
>
> PLEASE NOTE: This e-mail from Redpoint Global Inc. (“Redpoint”) is
> confidential and is intended solely for the use of the individual(s) to
> whom it is addressed. If you believe you received this e-mail in error,
> please notify the sender immediately, delete the e-mail from your computer
> and do not copy, print or disclose it to anyone else. If you properly
> received this e-mail as a customer, partner or vendor of Redpoint, you
> should maintain its contents in confidence subject to the terms and
> conditions of your agreement(s) with Redpoint.
>
> --
>
> Clebert Suconic
>
> PLEASE NOTE: This e-mail from Redpoint Global Inc. (“Redpoint”) is
> confidential and is intended solely for the use of the individual(s) to
> whom it is addressed. If you believe you received this e-mail in error,
> please notify the sender immediately, delete the e-mail from your computer
> and do not copy, print or disclose it to anyone else. If you properly
> received this e-mail as a customer, partner or vendor of Redpoint, you
> should maintain its contents in confidence subject to the terms and
> conditions of your agreement(s) with Redpoint.
>
-- 
Clebert Suconic

RE: Processing only one message

Posted by John Lilley <jo...@redpointglobal.com.INVALID>.
Clebert,

Thank for the reply!  I can see how to see this for the connection by adding this to the URL
?consumerWindowSize=0
https://activemq.apache.org/components/artemis/documentation/1.1.0/flow-control.html

I can also call setConsumerWindowSize(0) on the connection factory.

Can I set this explicitly on a consumer instance after it is created?

john




[rg] <https://www.redpointglobal.com/>

John Lilley

Chief Architect, Redpoint Global Inc.

888 Worcester Street, Suite 200 Wellesley, MA 02482

M: +1 7209385761<tel:+1%207209385761> | john.lilley@redpointglobal.com<ma...@redpointglobal.com>
From: Clebert Suconic <cl...@gmail.com>
Sent: Friday, September 30, 2022 3:02 AM
To: users@activemq.apache.org
Subject: Re: Processing only one message

*** [Caution] This email is from an external source. Please use caution responding, opening attachments or clicking embedded links. ***

Look at slow consumers.   Set consumer window size to 0 on this consumer.

On Thu, Sep 29, 2022 at 6:01 PM John Lilley <jo...@redpointglobal.com.invalid>> wrote:
We have an application that should read a single message from a queue (a “job” queue) and then stop processing more messages.  Think of it as a “batch request”.  This is entirely using the JMS driver. Is there a good pattern for this?

Under ActiveMQ 5, I call consumer.close(), session.close() from onMessage() and that works fine.  However, session.close() is not allowed under Artemis (and maybe it was always wrong).

I’ve tried calling only consumer.close(), and leave the session open.  But the message is not ACked.  Explicitly calling message.acknowledge() doesn’t work either, because it gets to >>> and individualAck is false:

public void acknowledge() throws JMSException {
   if (session != null) {
      try {
         if (session.isClosed()) {
            throw ActiveMQClientMessageBundle.BUNDLE.sessionClosed();
         }
>>>         if (individualAck) {
            message.individualAcknowledge();
         }

Going back to the original question, what is the recommended pattern for this?

Thanks
john


[rg]<https://linkprotect.cudasvc.com/url?a=https%3a%2f%2fwww.redpointglobal.com%2f&c=E,1,woI5c78_8f-DCJwnBAd2SB8ZQhLpa0H91b89ArK-kwPX0ToGxJQJmAWCo4pKKXorliMxDRxv9bVPLRhLdu50I9WBzrjdu8_-3xSL4nhKhbgAxC-hndfqanIBQp4,&typo=1>

John Lilley

Chief Architect, Redpoint Global Inc.

888 Worcester Street, Suite 200 Wellesley, MA 02482<https://www.google.com/maps/search/888+Worcester+Street,+Suite+200+Wellesley,+MA+02482?entry=gmail&source=g>

M: +1 7209385761<tel:+1%207209385761> | john.lilley@redpointglobal.com<ma...@redpointglobal.com>

PLEASE NOTE: This e-mail from Redpoint Global Inc. (“Redpoint”) is confidential and is intended solely for the use of the individual(s) to whom it is addressed. If you believe you received this e-mail in error, please notify the sender immediately, delete the e-mail from your computer and do not copy, print or disclose it to anyone else. If you properly received this e-mail as a customer, partner or vendor of Redpoint, you should maintain its contents in confidence subject to the terms and conditions of your agreement(s) with Redpoint.
--
Clebert Suconic

PLEASE NOTE: This e-mail from Redpoint Global Inc. (“Redpoint”) is confidential and is intended solely for the use of the individual(s) to whom it is addressed. If you believe you received this e-mail in error, please notify the sender immediately, delete the e-mail from your computer and do not copy, print or disclose it to anyone else. If you properly received this e-mail as a customer, partner or vendor of Redpoint, you should maintain its contents in confidence subject to the terms and conditions of your agreement(s) with Redpoint.

Re: Processing only one message

Posted by Clebert Suconic <cl...@gmail.com>.
Look at slow consumers.   Set consumer window size to 0 on this consumer.

On Thu, Sep 29, 2022 at 6:01 PM John Lilley
<jo...@redpointglobal.com.invalid> wrote:

> We have an application that should read a single message from a queue (a
> “job” queue) and then stop processing more messages.  Think of it as a
> “batch request”.  This is entirely using the JMS driver. Is there a good
> pattern for this?
>
>
>
> Under ActiveMQ 5, I call consumer.close(), session.close() from
> onMessage() and that works fine.  However, session.close() is not allowed
> under Artemis (and maybe it was always wrong).
>
>
>
> I’ve tried calling only consumer.close(), and leave the session open.  But
> the message is not ACked.  Explicitly calling message.acknowledge() doesn’t
> work either, because it gets to >>> and individualAck is false:
>
>
>
> *public void *acknowledge() *throws *JMSException {
>    *if *(*session *!= *null*) {
>       *try *{
>          *if *(*session*.isClosed()) {
>             *throw *ActiveMQClientMessageBundle.*BUNDLE*.sessionClosed();
>          }
> >>>         *if *(*individualAck*) {
>             *message*.individualAcknowledge();
>          }
>
>
>
> Going back to the original question, what is the recommended pattern for
> this?
>
>
>
> Thanks
>
> john
>
> [image: rg] <https://www.redpointglobal.com/>
>
> John Lilley
>
> Chief Architect, Redpoint Global Inc.
>
> 888 Worcester Street, Suite 200 Wellesley, MA 02482
> <https://www.google.com/maps/search/888+Worcester+Street,+Suite+200+Wellesley,+MA+02482?entry=gmail&source=g>
>
> *M: *+1 7209385761 <+1%207209385761> | john.lilley@redpointglobal.com
>
> PLEASE NOTE: This e-mail from Redpoint Global Inc. (“Redpoint”) is
> confidential and is intended solely for the use of the individual(s) to
> whom it is addressed. If you believe you received this e-mail in error,
> please notify the sender immediately, delete the e-mail from your computer
> and do not copy, print or disclose it to anyone else. If you properly
> received this e-mail as a customer, partner or vendor of Redpoint, you
> should maintain its contents in confidence subject to the terms and
> conditions of your agreement(s) with Redpoint.
>
-- 
Clebert Suconic