Documentation ¶
Overview ¶
Package consumer consolidates all the functions and methods for queue consumers. It implements a reconnection method as well.
Usage
con, err := consumer.New( consume.Server(server), consumer.Exchange(exchange), consume.Queue(queue), ) for server.Loop() { select { case msg := <-con.Subscribe(): // do things with the message } }
Index ¶
Constants ¶
const ENOEXCHANGE = "no exchange declared"
const ENOQUEUE = "no queue declared, can't consume without queues"
const ENOSERVER = "no valid server in rabbit"
ENOSERVER is returned when there's no valid server.Server definition. It may mean an error on the connection or the initialization.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Consumer ¶
type Consumer struct {
// contains filtered or unexported fields
}
A Consumer represents a RabbitMQ consumer of messages against a set of queues. It implements logic to have always a connection available where to receive messages from.
func New ¶
New returns a Consumer or an error if it's not in a working state. A Server argument is required, if it's missing it will return a rabbit.ENOCONN and if it's an incorrect value it will return a ENOSERVER.
func (*Consumer) RoutingKeys ¶
RoutingKeys returns a slice of all the routing keys being used against the queue in this consumer.
type Option ¶
func AutoAck ¶
func AutoAck() Option
AutoAck makes the consumer auto-acknowledge messages as soon as they are received.
func Exclusive ¶
func Exclusive() Option
Exclusive marks as true the exclusive value on the Consume method from AMQP.