Question

I have an async consumer configured via the spring-amqp framework:

<listener-container
    connection-factory="connectionFactory"
    message-converter="jsonMessageConverter"
    xmlns="http://www.springframework.org/schema/rabbit">
    <listener ref="requestHandler" method="handleMessage" queue-names="blah" />
</listener-container>

An external event from a 3rd party app indicates to my server that its ready to process data, at such a time I would like to take messages from the queue that I'm subscribed to and process them against the 3rd party app.

The job of my handleMessage method is to queue-up messages until the ready event from the 3rd party app is received. But I don't want to queue up too many, it would defeat the purpose of having RabbitMQ in the middle. Also, any optimization that can be achieved by NOT explicitly fetching messages when the ready event is received, would be lost.

Is there some way to indicate that I want to pause the subscription once an upperbound has been reached? Would QueueingConsumer be somehow relevant here?

Was it helpful?

Solution

Sounds like SimpleMessageListenerContainer.stop() is enough for you. Add an id attribute to your configuration and invoke that method when you need. And further you can invoke SimpleMessageListenerContainer.start() again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top