Description:
I'm using Logstash with RabbitMQ input plugin to read messages from a queue and write them to Elasticsearch. I want Logstash to only read the messages without consuming them (like a logger), but it's still consuming the messages from the queue.
Logstash should only read messages from RabbitMQ queue
Messages should remain in the queue after being read
Other consumers should be able to read the same messages
Logstash should act as a logger, not a consumer
Actual Behavior:
Logstash is consuming messages from the queue
Messages are being removed from the queue after being read
Other consumers cannot read the same messages
Setting ack => false is not preventing message consumption
Environment:
Logstash Version: [8.12.1]
RabbitMQ Version: [rabbitmq:3.13-management]
Steps to Reproduce:
Configure Logstash with the above configuration
Send messages to RabbitMQ queue
Observe that messages are being consumed from the queue
Check that other consumers cannot read the same messages
Additional Information:
This behavior is critical for our logging system where we need to preserve messages in the queue for other consumers
We've tried various configurations including different exchange types and queue settings
The issue persists regardless of the ack setting
Question:
Is this the expected behavior of the RabbitMQ input plugin? If not, how can we configure Logstash to only read messages without consuming them?
I believe so. Setting the ack option on the input determines the manual_ack setting when the input subscribes. If the ack option is true then the input will ack the message, if it is false then I think the March Hare library will auto-ack the message for you.
Thank you for your response. I've tried setting ack => true in my configuration, but the messages are still being consumed and removed from the queue. This behavior is not what we need since we want Logstash to only read the messages without consuming them, allowing other consumers to access the same messages.
Could you please clarify:
Is there any other configuration setting we need to adjust to prevent message consumption?
Are there any known limitations or workarounds for this behavior?
Would using a different exchange type or queue configuration help achieve our goal of message preservation?
I may be wrong, but I don't think that RabbitMQ works this way, if you have a consumer for a queue the messages will be consumed and removed from the queue, if you do not want this you need to do what Badger mentioned, which is basically duplicating your messages.
The behavior you want is more related to how Kafka works, where you can have a topic and multiple consumers reading from the topic without impacting each other if they use different group ids.
Maybe - suggestion without knowing if it's possible - create a read only user on the rabbitmq side for using in logstash, will do it?
But like this, how do you know if a message was previously costumed? The messages will be on the queue forever (if nobody removed it)...
... exactly what I was wondering. Something needs to keep track, or messages can be read 0, 1, or ... N times.
The terminology here doesn't help - reading a message != consuming a message? Is that really a widely understood industry standard distinction (in message queueing circles)?
It was an interesting approach , it might have worked. However, I realized that reading messages without consuming them caused duplicates in some cases. So, I mirrored all the messages to a different queue and connected Logstash to that queue, which solved my problem. Thanks.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.