rabbit

package
v0.1.30 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

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

Variables

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

Functions

func Init added in v0.1.19

func Init(rbInfo *RbInfo)

Types

type ConsumeOpt added in v0.1.19

type ConsumeOpt struct {
	NoLocal   bool
	NoAck     bool
	Exclusive bool
	NoWait    bool
	Arguments amqp.Table
}

type DialOption added in v0.1.19

type DialOption interface {
	// contains filtered or unexported methods
}

func WithConsumeOpt added in v0.1.19

func WithConsumeOpt(consumeOpt ConsumeOpt) DialOption

WithConsumeOpt Consume 参数

func WithDeadDurable added in v0.1.19

func WithDeadDurable(durable bool) DialOption

WithDeadDurable 死信队列是否持久化

func WithDeadExchangeOpt added in v0.1.19

func WithDeadExchangeOpt(exchangeOpt ExchangeDeclareOpt) DialOption

WithDeadExchangeOpt 死信交换机配置, 只有配置了死信队列才生效

func WithDeadQueueBindOpt added in v0.1.19

func WithDeadQueueBindOpt(queueBindOpt QueueBindOpt) DialOption

WithDeadQueueBindOpt 死信队列绑定配置, 只有配置了死信队列才生效

func WithDeadQueueOpt added in v0.1.19

func WithDeadQueueOpt(queueOpt QueueDeclareOpt) DialOption

WithDeadQueueOpt 死信队列配置, 只有配置了死信队列才生效

func WithDurable added in v0.1.19

func WithDurable(durable bool) DialOption

WithDurable 是否持久化

func WithExchangeOpt added in v0.1.19

func WithExchangeOpt(exchangeOpt ExchangeDeclareOpt) DialOption

WithExchangeOpt 交换机配置

func WithQueueBindOpt added in v0.1.19

func WithQueueBindOpt(queueBindOpt QueueBindOpt) DialOption

WithQueueBindOpt 队列绑定配置

func WithQueueOpt added in v0.1.19

func WithQueueOpt(queueOpt QueueDeclareOpt) DialOption

WithQueueOpt 队列配置

func WithReconnectDelay added in v0.1.19

func WithReconnectDelay(reconnectDelay time.Duration) DialOption

WithReconnectDelay 链接超时时间

func WithResendDelay added in v0.1.19

func WithResendDelay(resendDelay time.Duration) DialOption

WithResendDelay 发送超时时间

type ExchangeDeclareOpt added in v0.1.19

type ExchangeDeclareOpt struct {
	ExchangeType string
	AutoDelete   bool
	Internal     bool
	NoWait       bool
	Arguments    amqp.Table
}

type QueueBindOpt added in v0.1.19

type QueueBindOpt struct {
	NoWait    bool
	Arguments amqp.Table
}

type QueueDeclareOpt added in v0.1.19

type QueueDeclareOpt struct {
	AutoDelete bool
	Exclusive  bool
	NoWait     bool
	Arguments  amqp.Table
}

type RbInfo

type RbInfo struct {
	Addr             string
	ExchangeName     string
	QueueName        string
	RouteKey         string
	DeadExchangeName string
	DeadQueueName    string
	DeadRouteKey     string
	// contains filtered or unexported fields
}

type RbMqClient

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

func NewAndInitRabbitClient

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

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

func NewAndInitRabbitServer

func NewAndInitRabbitServer(rbInfo RbInfo, opts ...DialOption) (*RbMqClient, error)

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

func NewRabbitProduct

func NewRabbitProduct(rbInfo RbInfo, callBack func(amqp.Delivery), opts ...DialOption) (*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