Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add queue_durability property to amqp_consumer input #4628

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions plugins/inputs/amqp_consumer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ The following defaults are known to work with RabbitMQ:

## AMQP queue name
queue = "telegraf"

## AMQP queue durability.
queue_durability = true

## Binding Key
binding_key = "#"

Expand Down
22 changes: 13 additions & 9 deletions plugins/inputs/amqp_consumer/amqp_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ type AMQPConsumer struct {
ExchangeArguments map[string]string `toml:"exchange_arguments"`

// Queue Name
Queue string
Queue string `toml:"queue"`
QueueDurability bool `toml:"queue_durability"`
// Binding Key
BindingKey string `toml:"binding_key"`

Expand Down Expand Up @@ -98,10 +99,13 @@ func (a *AMQPConsumer) SampleConfig() string {
# exchange_arguments = { }
# exchange_arguments = {"hash_propery" = "timestamp"}

## AMQP queue name
## AMQP queue name.
queue = "telegraf"

## Binding Key
## AMQP queue durability.
queue_durability = true
snubydev marked this conversation as resolved.
Show resolved Hide resolved

## Binding Key.
binding_key = "#"

## Maximum number of messages server should give to the worker.
Expand Down Expand Up @@ -261,12 +265,12 @@ func (a *AMQPConsumer) connect(amqpConf *amqp.Config) (<-chan amqp.Delivery, err
}

q, err := ch.QueueDeclare(
a.Queue, // queue
true, // durable
false, // delete when unused
false, // exclusive
false, // no-wait
nil, // arguments
a.Queue, // queue
a.QueueDurability, // durable
false, // delete when unused
false, // exclusive
false, // no-wait
nil, // arguments
)
if err != nil {
return nil, fmt.Errorf("Failed to declare a queue: %s", err)
Expand Down