amqp

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: MIT Imports: 4 Imported by: 0

README

GitHub go.mod Go version (subdirectory of monorepo) Go Reference

Go RabbitMQ Consumer

This package uses the package provided by the RabbitMQ core team.

Goals

Provide auto reconnect

Installation

go get -u github.com/elvin-tacirzade/go-amqp

Usage

First we call a New() function. The function takes the following parameters:

  1. user - Declare a RabbitMQ user.
  2. password - Declare a RabbitMQ password
  3. host - Declare a RabbitMQ host
  4. port -Declare a RabbitMQ port
  5. reconnectTime - Declare an auto reconnect time

New() function returns the RabbitMQ struct and error.

See the example subdirectory for simple consumers executables.

Documentation

Overview

Package amqp provide auto reconnect for rabbitmq

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RabbitMQ

type RabbitMQ struct {
	Connection *amqp.Connection
	Channel    *amqp.Channel
	// contains filtered or unexported fields
}

RabbitMQ contains Connection and Channel

func New

func New(user, password, host, port string, reconnectTime time.Duration) (*RabbitMQ, error)

New connects to RabbitMQ and open a channel

func (*RabbitMQ) Consume

func (r *RabbitMQ) Consume(consumer string, autoAck, exclusive, noLocal, noWait bool, arguments amqp.Table) (<-chan amqp.Delivery, error)

Consume starts delivering queued messages

func (*RabbitMQ) ExchangeDeclare

func (r *RabbitMQ) ExchangeDeclare(name, exchangeType string, durable, autoDelete, internal, noWait bool, arguments amqp.Table) error

ExchangeDeclare declare an exchange

func (*RabbitMQ) Qos

func (r *RabbitMQ) Qos(prefetchCount, prefetchSize int, global bool) error

Qos controls how many messages or how many bytes the server will try to keep on the network for consumers before receiving delivery ack

func (*RabbitMQ) QueueBind

func (r *RabbitMQ) QueueBind(key, exchangeName string, noWait bool, arguments amqp.Table) error

QueueBind bind a queue

func (*RabbitMQ) QueueDeclare

func (r *RabbitMQ) QueueDeclare(name string, durable, autoDelete, exclusive, noWait bool, arguments amqp.Table) error

QueueDeclare declare a queue

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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