rabbitmq

package
v0.0.0-...-26e1b9e Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host         string `json:"host" yaml:"host"`                 //rabbitmq地址
	UserName     string `json:"userName" yaml:"userName"`         //用户名
	Password     string `json:"password" yaml:"password"`         //密码
	Port         int    `json:"port" yaml:"port"`                 //端口号
	Vhost        string `json:"vhost" yaml:"vhost"`               //rabbitmq虚拟主机
	QueueName    string `json:"queueName" yaml:"queueName"`       //队列名
	Exchange     string `json:"exchange" yaml:"exchange"`         //交换机
	ExchangeType string `json:"exchangeType" yaml:"exchangeType"` //交换机类型
	RoutingKey   string `json:"routingKey" yaml:"routingKey"`     //路由键
	Tag          string `json:"tag" yaml:"tag"`                   //标签
}

Config rabbit配置结构体

type Consumer

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

Consumer 消费者结构体

func GetConsumer

func GetConsumer(name string) *Consumer

func NewConsumer

func NewConsumer(config *Config) *Consumer

NewConsumer 构造消费者

func (*Consumer) AnnounceQueue

func (c *Consumer) AnnounceQueue(queueName, bindingKey string) (<-chan amqp.Delivery, error)

AnnounceQueue 根据路由键重新绑定队列

func (*Consumer) Connect

func (c *Consumer) Connect() error

Connect to RabbitMQ server

func (*Consumer) Handle

func (c *Consumer) Handle(fn func(<-chan amqp.Delivery), threads int)

Handle 具体的消费者处理逻辑

func (*Consumer) ReConnect

func (c *Consumer) ReConnect() error

ReConnect 消费者端的重连

func (*Consumer) Shutdown

func (c *Consumer) Shutdown() error

Shutdown 关闭管道和连接

type Producer

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

Producer 生产者结构体

func GetProducer

func GetProducer(name string) *Producer

func NewProducer

func NewProducer(config *Config) *Producer

NewProducer 构造生产者

func (*Producer) Connect

func (c *Producer) Connect() (err error)

Connect 连接RabbitMq

func (*Producer) Publish

func (c *Producer) Publish(msg interface{}) error

Publish 推送消息

func (*Producer) Reconnect

func (c *Producer) Reconnect() error

Reconnect 生产者断线重连机制

func (*Producer) Shutdown

func (c *Producer) Shutdown() error

Shutdown 关闭管道和连接

Jump to

Keyboard shortcuts

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