You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by brianbaquiran <br...@gmail.com> on 2008/03/14 03:41:35 UTC

Pausing a consumer

Hello,
Is there a way to temporarily pause or throttle messages received by a
consumer using a messageListener?

I'm writing a program that takes messages from a queue and sends them to a
process on a remote server using a proprietary TCP protocol. Unfortunately,
the protocol/remote server handles a fixed 'window' of messages at a time.
Once the n messages are sent, my client program has to wait for
acknowledgements  before sending more messages. Each message the client send
gets an ack from the remote server, and acks may come in any order.

So now I'm looking for a way to turn off the messageListener when the number
of unacknowledged messages reaches the maximum number allowed, and turn on
the messageListener as soon as I receive an ack from the server. Is there a
correct way to do this?
-- 
View this message in context: http://www.nabble.com/Pausing-a-consumer-tp16043150s2354p16043150.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Pausing a consumer

Posted by brianbaquiran <br...@gmail.com>.
Oh, and in case it matters, I am using pyactivemq (Python wrapper for
ActiveMQ-CPP).

Thanks in advance.
-- 
View this message in context: http://www.nabble.com/Pausing-a-consumer-tp16043150s2354p16044462.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Pausing a consumer

Posted by James Strachan <ja...@gmail.com>.
Just add a sleep in your consumer.

2008/3/14 brianbaquiran <br...@gmail.com>:
>
> Hello,
> Is there a way to temporarily pause or throttle messages received by a
> consumer using a messageListener?
>
> I'm writing a program that takes messages from a queue and sends them to a
> process on a remote server using a proprietary TCP protocol. Unfortunately,
> the protocol/remote server handles a fixed 'window' of messages at a time.
> Once the n messages are sent, my client program has to wait for
> acknowledgements  before sending more messages. Each message the client send
> gets an ack from the remote server, and acks may come in any order.
>
> So now I'm looking for a way to turn off the messageListener when the number
> of unacknowledged messages reaches the maximum number allowed, and turn on
> the messageListener as soon as I receive an ack from the server. Is there a
> correct way to do this?
> --
> View this message in context: http://www.nabble.com/Pausing-a-consumer-tp16043150s2354p16043150.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>



-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Re: Pausing a consumer

Posted by "Jahvid.Williams" <ja...@napkasystems.com>.


brianbaquiran wrote:
> 
> Hello,
> Is there a way to temporarily pause or throttle messages received by a
> consumer using a messageListener?
> 
As far as i have found in the on_message method for your MessageListener
class you could attempt to slow down the message consumption process,
possibly with a time.sleep(x amt of time).


brianbaquiran wrote:
> 
> So now I'm looking for a way to turn off the MessageListener when the
> number of unacknowledged messages reaches the maximum number allowed, and
> turn on the MessageListener as soon as I receive an ack from the server.
> Is there a correct way to do this?
> 

Im not sure about turning acknowledgments off, but if you wanted to filter
how many messages that can be sent over to your server at a time why not
send a batch of messages over in a queue/list. 
 So lets say the server is capable of handling 1000 messages a minute, why
not have a queue/list that stores 500 messages per transfer and dispatch
them to the server (bear in mind given the size of the messages this could
end up using extra bandwidth). 

-----
“A foolish man tells a woman to stop talking, but a wise man tells her that
her mouth is extremely beautiful when her lips are closed”
-- 
View this message in context: http://www.nabble.com/Pausing-a-consumer-tp16043150p21464843.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.