rabbit

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReconnectDelay = 10 // 连接断开后多久重连
	ResendDelay    = 3  // 消息发送超时时间
)

Variables

View Source
var (
	ParamsError   = errors.New("地址、路由和队列不能为空")
	CallBackError = errors.New("消费回调函数不能为空")
)

Functions

This section is empty.

Types

type RbInfo

type RbInfo struct {
	Addr             string
	ExchangeName     string
	QueueName        string
	RouteKey         string
	DeadExchangeName string
	DeadQueueName    string
	DeadRouteKey     string
}

type RbMqClient

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

func NewAndInitRabbitClient

func NewAndInitRabbitClient(rbInfo RbInfo, callBack func(amqp.Delivery) bool) (*RbMqClient, error)

NewAndInitRabbitClient 新建消费端(消费消息)

func NewAndInitRabbitServer

func NewAndInitRabbitServer(rbInfo RbInfo) (*RbMqClient, error)

NewAndInitRabbitServer 新建服务端(发布消息)

func NewRabbitProduct

func NewRabbitProduct(rbInfo RbInfo, callBack func(amqp.Delivery) bool) (*RbMqClient, error)

func (*RbMqClient) Close

func (rabbitProduct *RbMqClient) Close()

Close 关闭, 如果不关闭的话, channel 不会释放

func (*RbMqClient) Consume

func (rabbitProduct *RbMqClient) Consume(prefetchCount int)

Consume 消费消息 prefetchCount 预取数量,设置为1的话,可以实现性能高的服务器消费的数量多

func (*RbMqClient) InitRabbitProduct

func (rabbitProduct *RbMqClient) InitRabbitProduct()

func (*RbMqClient) Publish

func (rabbitProduct *RbMqClient) Publish(msg []byte) bool

Publish 发布消息

func (*RbMqClient) PublishMulti

func (rabbitProduct *RbMqClient) PublishMulti(msgs [][]byte) (bool, int)

PublishMulti 返回发送是否全部成功和发送成功的数量

Jump to

Keyboard shortcuts

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