publisher

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(p *Publisher)

Option allows to configure RabbitMQ Publisher.

func WithConstHeaders

func WithConstHeaders(headers amqp.Table) Option

WithConstHeaders sets constant publishing headers, that will be added to all publishings.

func WithExpiration

func WithExpiration(expire time.Duration) Option

WithExpiration sets publishing Expire property.

func WithImmediate

func WithImmediate() Option

WithImmediate sets server to discard a message when no consumer on the matched queue is ready to accept the delivery and server will return an undeliverable message with a Return method. See https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.publish.immediate.

func WithMandatory

func WithMandatory() Option

WithMandatory sets server to discard a message if no queue is bound that matches the routing key and server will return an undeliverable message with a Return method. See https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.publish.mandatory.

func WithTransientDeliveryMode

func WithTransientDeliveryMode() Option

WithTransientDeliveryMode sets publishing to the Transient delivery mode. Transient means higher throughput but messages will not be restored on broker restart. See https://github.com/rabbitmq/amqp091-go/blob/main/types.go#L123.

type Publisher

type Publisher struct {
	// contains filtered or unexported fields
}

Publisher is a Publisher to RabbiMQ.

func New

func New(channel publish.Channel, exchange string, ops ...Option) Publisher

New creates new RabbitMQ Publisher. By default, it will publish with Persistent delivery mode, mandatory=false, immediate=false and empty args. Pass Options to configure it as you wish.

func (Publisher) Publish

func (p Publisher) Publish(ctx context.Context, key string, message []byte, mws ...publish.Middleware) error

Publish message with routing key.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL