jasonrbriggs / stomp.py

“stomp.py” is a Python client library for accessing messaging servers (such as ActiveMQ or RabbitMQ) using the STOMP protocol (versions 1.0, 1.1 and 1.2). It can also be run as a standalone, command-line client for testing.
Apache License 2.0
495 stars 166 forks source link

Support for prefetchSize set to 0? #289

Closed Soarnsky closed 4 years ago

Soarnsky commented 4 years ago

For my use case, we use ActiveMQ as a task queue. Consumer processes the task extremely slowly, around 1-2 hours, so I distribute it across 6 consumers. Low number of messages, long time to process, so having prefetchSize set to 0 to have the consumer request messages instead seems to fit my use case.

Is there any way to do this now that I'm not seeing here? If not can prefetchSize set to 0 be supported with a receive() method in the Connection?

jasonrbriggs commented 4 years ago

You can send additional headers when you subscribe. According to this link...

https://activemq.apache.org/stomp.html

...you can send the prefetchSize then. Is that what you mean?

Soarnsky commented 4 years ago

Right, the problem is when I set prefetchSize to 0, there's an AttributeError for StompConnection. Missing method receive()

jasonrbriggs commented 4 years ago

StompConnection doesn't accept additional headers. You can pass them on connect - which seems to work for me (no errors at least). Looking at the docs though it seems like the prefetchSize header should be provided on subscribe though.

madkote commented 4 years ago

@jasonrbriggs @Soarnsky on connect pass: headers={'activemq.prefetchSize': <SOME_VALUE_INT>}

so it can be closed.