diff --git a/v4/broker/rabbitmq/options.go b/v4/broker/rabbitmq/options.go index 4a31846e..790076b8 100644 --- a/v4/broker/rabbitmq/options.go +++ b/v4/broker/rabbitmq/options.go @@ -5,6 +5,7 @@ import ( "time" "go-micro.dev/v4/broker" + "go-micro.dev/v4/client" ) type durableQueueKey struct{} @@ -164,3 +165,14 @@ type ackSuccessKey struct{} func AckOnSuccess() broker.SubscribeOption { return setSubscribeOption(ackSuccessKey{}, true) } + +// PublishDeliveryMode client.PublishOption for setting message "delivery mode" +// mode , Transient (0 or 1) or Persistent (2) +func PublishDeliveryMode(mode uint8) client.PublishOption { + return func(o *client.PublishOptions) { + if o.Context == nil { + o.Context = context.Background() + } + o.Context = context.WithValue(o.Context, deliveryMode{}, mode) + } +}