consumer

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyClosed = errors.New("consumer.Listener: already closed")

ErrAlreadyClosed is returned by the consumer when closing a previously-closed Listener.

Functions

func AutoAck

func AutoAck(listener *Listener)

AutoAck automatically acknowledges a message as soon as the AMQP broker delivers it to the Consumer.

This might lead to message loss scenarios in case the consumer gets abruptly closed.

func Exclusive

func Exclusive(listener *Listener)

Exclusive ensures that this consumer is the only one consuming messages for the specified queue.

func NoWait

func NoWait(listener *Listener)

NoWait does not wait for the AMQP broker to confirm the "consume" request and immediately begin deliveries.

Types

type Listener

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

Listener allows to listen for incoming messages from a consumer, which is attached to one or more queues.

Use Listen function to create a new Listener instance.

func Listen

func Listen(queue string, options ...Option) Listener

Listen returns a new Listener able to listen and serve incoming messages on one or more AMQP queues.

func (*Listener) Close

func (srv *Listener) Close(ctx context.Context) error

func (*Listener) Closed

func (srv *Listener) Closed() <-chan error

func (Listener) Listen

Listen starts listening to incoming messages on the specified queue (or queues) using the provided Connection or Channel, and serving them by using the provided Handler.

An error is returned if the Listener is unable to start listening on the provided Channel.

type Option

type Option func(*Listener)

Option is an optional functionality that can be added to the Listener that is being initialized by the Listen factory method.

func Arguments

func Arguments(args amqp.Table) Option

Arguments specifies optional arguments to be supplied during queue declaration.

Multiple calls of this option are supported.

func Description

func Description(description string) Option

Description adds a description for the consumer.

func OnError

func OnError(fn func(amqp.Delivery, error)) Option

OnError specifies the callback function to execute when the message handler fails with an error, providing the amqp.Delivery and the error returned by the handler itself.

If not specified, the Server will call amqp.Delivery.Nack(false, true).

func OnSuccess

func OnSuccess(fn func(amqp.Delivery)) Option

OnSuccess specifies the callback function to execute when the message handler successfully processed the message (i.e. failed without an error).

If not specified, the Server will call amqp.Delivery.Ack(false).

func Title

func Title(title string) Option

Title adds a title for the consumer.

Jump to

Keyboard shortcuts

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