rmq

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

README

rmq

Go client for rabbitmq

Documentation

Index

Constants

View Source
const (
	ExchangeDirect  = "direct"
	ExchangeFanout  = "fanout"
	ExchangeTopic   = "topic"
	ExchangeHeaders = "headers"
)

Constants for standard AMQP 0-9-1 exchange types.

View Source
const (
	Transient  uint8 = 1
	Persistent uint8 = 2
)

DeliveryMode. Transient means higher throughput but messages will not be restored on broker restart. The delivery mode of publishings is unrelated to the durability of the queues they reside on. Transient messages will not be restored to durable queues, persistent messages will be restored to durable queues and lost on non-durable queues during server restart.

This remains typed as uint8 to match Publishing.DeliveryMode. Other delivery modes specific to custom queue implementations are not enumerated here.

View Source
const (
	LevelEmergency = iota
	LevelAlert
	LevelCritical
	LevelError
	LevelWarning
	LevelNotice
	LevelInformational
	LevelDebug
)

Variables

This section is empty.

Functions

func Debug

func Debug(enable bool)

Debug Enable debug

func Publish

func Publish(messages chan Message, c *Client)

Publish rabbitmq publish

func PublishWithRoutingKey

func PublishWithRoutingKey(messages chan MessageWithRoutingKey, c *Client)

PublishWithRoutingKey rabbitmq publish

func SetUserDebug added in v1.0.2

func SetUserDebug(f TraceFunc)

SetUserDebug 配置其他日志输出

func Subscribe

func Subscribe(handle CallBack, c *Client)

Subscribe rabbitmq subscribe

func TraceError

func TraceError(format string, v ...interface{})

TraceError 错误日志

func TraceInfo

func TraceInfo(format string, v ...interface{})

TraceInfo 调试信息日志

Types

type CallBack

type CallBack func(msg []byte)

CallBack callback function

type Client

type Client struct {
	URL                 string // rmqurl used to connect rabbitmq services
	ExchangeEnable      bool   // enable or disable queue bind
	Exchange            string // exchange binds the publishers to the subscribers
	ExchangeType        string // type of exchange
	QueueBindEnable     bool   // enable or disable queue bind
	QueueName           string // name of queue
	RoutingKey          string // routing key of queue
	Qos                 int    // qos of subscribe
	MsgExpirationEnable bool   // enable or disable message expiration
	ExpirationTime      int32  // expiration time of message
	DeliveryMode        uint8  // delivery mode of message
	PublishStatus       bool   // publish status
}

Client rabbitmq客户端信息

func NewClient

func NewClient() *Client

NewClient 创建一个默认的客户端信息

func (*Client) GetPublishStatus

func (c *Client) GetPublishStatus() bool

GetPublishStatus 获取生产者状态

func (*Client) Identity

func (c *Client) Identity() string

Identity returns the same host/process unique string for the lifetime of this process so that subscriber reconnections reuse the same queue name.

func (*Client) Info

func (c *Client) Info()

Info 客户端配置信息

func (*Client) SetDeliveryMode

func (c *Client) SetDeliveryMode(dMode uint8)

SetDeliveryMode 设置消息投递模式

func (*Client) SetExchange

func (c *Client) SetExchange(ex, exType string)

SetExchange 设置交换器信息

func (*Client) SetExchangeEnable

func (c *Client) SetExchangeEnable(enable bool)

SetExchangeEnable 设置是否需要定义交换器

func (*Client) SetExpirationTime

func (c *Client) SetExpirationTime(time int32)

SetExpirationTime 设置消息过期时间, 单位ms

func (*Client) SetMsgExpirationEnable

func (c *Client) SetMsgExpirationEnable(enable bool)

SetMsgExpirationEnable 设置消息是否过期

func (*Client) SetPublishStatus

func (c *Client) SetPublishStatus(status bool)

SetPublishStatus 设置生产者状态

func (*Client) SetQos

func (c *Client) SetQos(qos int)

SetQos 设置Qos值

func (*Client) SetQueueBindEnable

func (c *Client) SetQueueBindEnable(enable bool)

SetQueueBindEnable 设置是否需要声明和绑定到交换器

func (*Client) SetQueueName

func (c *Client) SetQueueName(q string)

SetQueueName 设置队列名称

func (*Client) SetRoutingKey

func (c *Client) SetRoutingKey(rkey string)

SetRoutingKey 设置routingKey

func (*Client) SetURL

func (c *Client) SetURL(url, vhost, username, password string)

SetURL 设置客户端的连接信息

type Message

type Message []byte

Message is the application type for a message. This can contain identity, or a reference to the recevier chan for further demuxing.

type MessageWithRoutingKey

type MessageWithRoutingKey struct {
	RoutingKey string
	Message    []byte
}

MessageWithRoutingKey is the application type for a message with routing key

type Session

type Session struct {
	*amqp.Connection
	*amqp.Channel
}

Session composes an amqp.Connection with an amqp.Channel

func (Session) Close

func (s Session) Close() error

Close tears the connection down, taking the channel with it.

type TraceFunc

type TraceFunc func(format string, level int, v ...interface{})
var UserTrace TraceFunc = nil

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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