From 46fc38531ac07ef70fe9ab13b944628bfb039a1d Mon Sep 17 00:00:00 2001 From: Guillem Date: Mon, 12 Feb 2024 12:19:30 -0300 Subject: [PATCH] Allow writing to a given exchange --- config.go | 3 +++ destination.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/config.go b/config.go index e26beb2..50a4a75 100644 --- a/config.go +++ b/config.go @@ -40,6 +40,9 @@ type DestinationConfig struct { // ContentType is the MIME content type of the messages written to rabbitmq ContentType string `json:"contentType" default:"text/plain"` + + // Exchange is the name of the exchange to publish to + Exchange string `json:"exchange" default:""` } func newDestinationConfig(cfg map[string]string) (DestinationConfig, error) { diff --git a/destination.go b/destination.go index 975feb7..f5eb6bf 100644 --- a/destination.go +++ b/destination.go @@ -80,7 +80,7 @@ func (d *Destination) Write(ctx context.Context, records []sdk.Record) (int, err Body: record.Payload.After.Bytes(), } - err := d.ch.PublishWithContext(ctx, "", d.config.QueueName, false, false, msg) + err := d.ch.PublishWithContext(ctx, d.config.Exchange, d.config.QueueName, false, false, msg) if err != nil { return 0, fmt.Errorf("failed to publish: %w", err) }