mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
Add headers into AMQP notifications (#12911)
Signed-off-by: Ricardo Katz <rkatz@vmware.com>
This commit is contained in:
parent
65b6f4aa31
commit
a526ad2e80
@ -140,6 +140,8 @@ $ mc admin config set myminio/ notify_amqp:1 exchange="bucketevents" exchange_ty
|
||||
|
||||
MinIO supports all the exchanges available in [RabbitMQ](https://www.rabbitmq.com/). For this setup, we are using `fanout` exchange.
|
||||
|
||||
MinIO also sends with the notifications two headers: `minio-bucket` and `minio-event`. An exchange using the type "headers" can use this information to route the notifications to proper queues.
|
||||
|
||||
Note that, you can add as many AMQP server endpoint configurations as needed by providing an identifier (like "1" in the example above) for the AMQP instance and an object of per-server configuration parameters.
|
||||
|
||||
### Step 2: Enable bucket notification using MinIO client
|
||||
|
@ -222,6 +222,11 @@ func (target *AMQPTarget) send(eventData event.Event, ch *amqp.Channel, confirms
|
||||
return err
|
||||
}
|
||||
|
||||
headers := make(amqp.Table)
|
||||
// Add more information here as required, but be aware to not overload headers
|
||||
headers["minio-bucket"] = eventData.S3.Bucket.Name
|
||||
headers["minio-event"] = eventData.EventName.String()
|
||||
|
||||
if err = ch.ExchangeDeclare(target.args.Exchange, target.args.ExchangeType, target.args.Durable,
|
||||
target.args.AutoDeleted, target.args.Internal, target.args.NoWait, nil); err != nil {
|
||||
return err
|
||||
@ -229,6 +234,7 @@ func (target *AMQPTarget) send(eventData event.Event, ch *amqp.Channel, confirms
|
||||
|
||||
if err = ch.Publish(target.args.Exchange, target.args.RoutingKey, target.args.Mandatory,
|
||||
target.args.Immediate, amqp.Publishing{
|
||||
Headers: headers,
|
||||
ContentType: "application/json",
|
||||
DeliveryMode: target.args.DeliveryMode,
|
||||
Body: data,
|
||||
|
Loading…
Reference in New Issue
Block a user