Subscriber stops receiving messages. #672
gaurav-gupta123
started this conversation in
General
Replies: 1 comment 1 reply
-
Start with inspecting server logs. You can make Bunny log at debug level, too. We do not guess in the RabbitMQ community. Two issues stand out in your code:
If you need to process deliveries concurrently and are sure you understand the risks in doing so (e.g. your deliveries can be processed in parallel because they do not depend on one another in any way), then dispatching deliveries to a thread pool any way you like should be enough: @connection.start
ch = @connection.create_channel
q = ch.queue('test_queue', durable: true)
queue.subscribe(manual_ack: true) do |delivery_info, _properties, payload|
puts "=====Received Payload #{payload}====="
# This is just an example. I cannot know what thread pool implementation you will use
# and what API it will have. But dispatching a delivery processing to it
# will allow Bunny delivery dispatcher to move on to the next delivery
pool.submit do
# do something with the delivery
end
# it's a better idea to ack here to avoid double acknowledgements
# https://rabbitmq.com/confirms.html#consumer-acks-double-acking
#
# If you are sure that double acknowledging is not a risk, you can choose
# to acknowledge in the submit block above, right after doing the actual work
# on/with the delivery
channel.ack(delivery_info.delivery_tag)
end
# keep the thread alive to let the connection-channel and consumer run
loop do
sleep 1
end |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've integrated Bunny Gem for publishing and subscribing the active record events like create update, destroy the object among distributed systems.
As of now, it is working fine, but whenever there is no activity for a few minutes like 5 minutes after that subscriber stops receiving further messages. All the messages get piled up in the queue.
Below is the sample code and configuration for subscribing to the queue:
Kindly help me out If I missed something.
Beta Was this translation helpful? Give feedback.
All reactions