rabbitmqx

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: MIT Imports: 3 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 {
	MqUrl      string // 消息队列连接地址配置
	Exchange   string // 交换机
	RoutingKey string // 路由键
	Queue      string // 队列名
	ExType     string // 交换机类型
}

Config rabiitmq配置的抽象

func NewConfigByMap

func NewConfigByMap(setting map[string]interface{}) *Config

NewConfigByMap 从map[string]interface{}中新建一个Config

type Consumer

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

Consumer 消费者

func NewConsumer

func NewConsumer(mqUrl string) (*Consumer, error)

NewConsumer 新建自定义的消费者

func NewConsumerByConfig

func NewConsumerByConfig(c *Config) (*Consumer, error)

NewConsumerByConfig 通过Config

func NewDelayedQueueConsumer

func NewDelayedQueueConsumer(config *Config) (*Consumer, error)

NewDelayedQueueConsumer 新建一个延迟队列的消费者。使用rabbitmq_delayed_message_exchange插件实现的延迟队列 因此需要安装对应版本的插件

func (*Consumer) Close

func (c *Consumer) Close() error

Close 关闭

func (*Consumer) Consume

func (c *Consumer) Consume(handler rabbitmq.Handler) error

Consume 消费

func (*Consumer) SetExchange

func (c *Consumer) SetExchange(exchange string, exType string)

SetExchange 设置交换机

func (*Consumer) SetOptions

func (c *Consumer) SetOptions(options []func(*rabbitmq.ConsumeOptions))

SetOptions 设置Options

func (*Consumer) SetQueue

func (c *Consumer) SetQueue(queue string)

SetQueue 设置消费队列

func (*Consumer) SetRoutingKey

func (c *Consumer) SetRoutingKey(routingKey []string)

SetRoutingKey 设置routingKey

type Publisher

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

func NewDelayedQueuePulisher

func NewDelayedQueuePulisher(config *Config) (*Publisher, error)

NewDelayedQueuePulisher 创建一个publisher,使用DeleayedQueueConfig的配置

func NewPublisher

func NewPublisher(mqUrl string) (*Publisher, error)

NewPublisher 新建自定义的发送者

func NewPublisherByConfig

func NewPublisherByConfig(c *Config) (*Publisher, error)

NewPublisherByConfig 通过Config创建Publisher

func (*Publisher) Close

func (p *Publisher) Close() error

Close 关闭消息推送者

func (*Publisher) Publish

func (p *Publisher) Publish(msg []byte) error

Publish 推送消息

func (*Publisher) PublishDelayed

func (p *Publisher) PublishDelayed(msg []byte, ttl int64) error

PublishDelayed 发送延迟消息,ttl是毫秒为单位

func (*Publisher) SetExchange

func (p *Publisher) SetExchange(exchange string)

SetExchange 设置交换机

func (*Publisher) SetOptions

func (p *Publisher) SetOptions(options []func(*rabbitmq.PublishOptions))

SetOptions 设置Options

func (*Publisher) SetRoutingKey

func (p *Publisher) SetRoutingKey(routingKey []string)

SetRoutingKey 设置路由键

Jump to

Keyboard shortcuts

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