Documentation
¶
Index ¶
Constants ¶
const (
SIRIUS_RABBITMQ = "amqp://guest:guest@sirius-rabbitmq:5672/"
)
Variables ¶
This section is empty.
Functions ¶
func Listen ¶
func Listen(qName string, messageProcessor MessageProcessor)
Listen listens to a RabbitMQ queue specified by qName and processes messages using the provided messageProcessor function. WARNING: This function calls log.Fatalf on connection failure, killing the entire process. For resilient listening with automatic reconnection, use ListenWithRetry instead.
func ListenWithRetry ¶ added in v0.0.14
func ListenWithRetry(ctx context.Context, qName string, messageProcessor MessageProcessor)
ListenWithRetry listens to a RabbitMQ queue with automatic reconnection. Unlike Listen, this function does NOT call log.Fatalf on failure. Instead it retries the connection with exponential backoff (1s → 30s cap) and automatically reconnects if the broker drops the connection. The listener stops cleanly when ctx is cancelled.
Types ¶
type MessageProcessor ¶
type MessageProcessor func(msg string)
MessageProcessor is a type for functions that can process messages.