category
4/11/2017 - 3:54 PM

stomp.py - Configure stomp consumer to have a prefetch limit of 1

stomp.py - Configure stomp consumer to have a prefetch limit of 1

First of all configure the queue connection to have a prefetchSize of one:

self.connection.subscribe(destination=queueName, id=1, ack='client', headers={'consumer.prefetchSize': 1})

Then, pass the connection as an argument into the listener class and ack the message under the on_message method:

 def on_message(self, headers, message):
 self.connection.ack(headers['message-id'], headers['subscription'])