feat(inputs.amqp_consumer): Add support to rabbitmq stream queue (#13496)

This commit is contained in:
massimogallina 2023-06-27 19:40:27 +02:00 committed by GitHub
parent 2e957cc003
commit ef86635d21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 10 deletions

View File

@ -73,6 +73,10 @@ See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
## If true, queue will be passively declared.
# queue_passive = false
## Additional arguments when consuming from Queue
# queue_consume_arguments = { }
# queue_consume_arguments = {"x-stream-offset" = "first"}
## A binding between the exchange and queue using this binding key is
## created. If unset, no binding is created.
binding_key = "#"

View File

@ -40,9 +40,10 @@ type AMQPConsumer struct {
MaxUndeliveredMessages int `toml:"max_undelivered_messages"`
// Queue Name
Queue string `toml:"queue"`
QueueDurability string `toml:"queue_durability"`
QueuePassive bool `toml:"queue_passive"`
Queue string `toml:"queue"`
QueueDurability string `toml:"queue_durability"`
QueuePassive bool `toml:"queue_passive"`
QueueConsumeArguments map[string]string `toml:"queue_consume_arguments"`
// Binding Key
BindingKey string `toml:"binding_key"`
@ -284,14 +285,19 @@ func (a *AMQPConsumer) connect(amqpConf *amqp.Config) (<-chan amqp.Delivery, err
return nil, fmt.Errorf("failed to set QoS: %w", err)
}
consumeArgs := make(amqp.Table, len(a.QueueConsumeArguments))
for k, v := range a.QueueConsumeArguments {
consumeArgs[k] = v
}
msgs, err := ch.Consume(
q.Name, // queue
"", // consumer
false, // auto-ack
false, // exclusive
false, // no-local
false, // no-wait
nil, // arguments
q.Name, // queue
"", // consumer
false, // auto-ack
false, // exclusive
false, // no-local
false, // no-wait
consumeArgs, // arguments
)
if err != nil {
return nil, fmt.Errorf("failed establishing connection to queue: %w", err)

View File

@ -34,6 +34,10 @@
## If true, queue will be passively declared.
# queue_passive = false
## Additional arguments when consuming from Queue
# queue_consume_arguments = { }
# queue_consume_arguments = {"x-stream-offset" = "first"}
## A binding between the exchange and queue using this binding key is
## created. If unset, no binding is created.
binding_key = "#"