Documentation ¶
Index ¶
- Variables
- func DestroyQueueName(name string) (string, string, string)
- func NewProvider(node esb.Node, logger log.Logger, client *Client) *rabbitProvider
- type Binding
- type Client
- func (c *Client) Close()
- func (c *Client) CloseConsumer(name string) error
- func (c *Client) CloseProducer(name string) error
- func (c *Client) Consumer(name string) (*Consumer, error)
- func (c *Client) Open() (mq *Client, err error)
- func (c *Client) Producer(name string) (*Producer, error)
- func (c *Client) State() uint8
- type ConsumeOption
- type Consumer
- func (c *Consumer) Close()
- func (c *Consumer) CloseChan()
- func (c *Consumer) Name() string
- func (c *Consumer) Open() error
- func (c *Consumer) SetExchangeBinds(eb []*ExchangeBinds) *Consumer
- func (c *Consumer) SetMsgCallback(cb chan<- Delivery) *Consumer
- func (c *Consumer) SetQos(prefetch int) *Consumer
- func (c *Consumer) State() uint8
- type Delivery
- type Exchange
- type ExchangeBinds
- type Option
- type Producer
- func (p *Producer) Close()
- func (p *Producer) Confirm(enable bool) *Producer
- func (p *Producer) ForDirect(exchange, route, queue, data string) error
- func (p *Producer) ForFanout(exchange, data string) error
- func (p *Producer) ForQueueArgs(exchange, route, kind string, bindings []*Binding, data []byte) error
- func (p *Producer) ForTopic(exchange, route, queue, data string) error
- func (p *Producer) IsOpen() bool
- func (p *Producer) Name() string
- func (p *Producer) Open() error
- func (p *Producer) Publish(exchange, route string, msg *PublishMsg) error
- func (p *Producer) SetExchangeBinds(eb []*ExchangeBinds) *Producer
- func (p *Producer) State() uint8
- type PublishMsg
- type Queue
Constants ¶
This section is empty.
Variables ¶
View Source
var ( StateClosed = uint8(0) StateOpened = uint8(1) StateReopening = uint8(2) )
Functions ¶
func DestroyQueueName ¶
DestroyQueueName 使用当前客户端分解一个ESB消息的队列名称,{name}名称满足格式:sys_esb_{systemId}_{node} 其中{systemId}为目标系统的四位数数字ID,{node}为目标系统监听的ESB节点标示(参考{@link ESBNode}。
@param name ESB消息的队列名称 @return "sys_esb","{systemId}","{node}"
Types ¶
type Binding ¶
type Binding struct { RouteKey string Queues []*Queue NoWait bool // 默认为false Args amqp.Table // 默认为nil }
Binding routeKey ==>队列
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) CloseConsumer ¶
func (*Client) CloseProducer ¶
type ConsumeOption ¶
ConsumeOption 消费者消费选项
func DefaultConsumeOption ¶
func DefaultConsumeOption() *ConsumeOption
type Consumer ¶
type Consumer struct {
// contains filtered or unexported fields
}
Consumer 基于RabbitMQ消息中间件的客户端实现。
func (*Consumer) SetExchangeBinds ¶
func (c *Consumer) SetExchangeBinds(eb []*ExchangeBinds) *Consumer
func (*Consumer) SetMsgCallback ¶
type Exchange ¶
type Exchange struct { Name string Kind string Durable bool AutoDelete bool Internal bool NoWait bool Args amqp.Table // 默认为nil }
Exchange 基于amqp的Exchange配置
type ExchangeBinds ¶
ExchangeBinds exchange ==> routeKey ==> queues
type Producer ¶
type Producer struct {
// contains filtered or unexported fields
}
Producer 基于RabbitMQ的生产者封装。
func (*Producer) Confirm ¶
Confirm 是否开启生产者confirm功能, 默认为false, 该选项在Open()前设置. 说明: 目前仅实现串行化的confirm, 每次的等待confirm额外需要约50ms,建议上层并发调用Publish
func (*Producer) ForQueueArgs ¶
func (*Producer) Publish ¶
func (p *Producer) Publish(exchange, route string, msg *PublishMsg) error
Publish 在同步Publish Confirm模式下, 每次Publish将额外有约50ms的等待时间.如果采用这种模式,建议上层并发publish
func (*Producer) SetExchangeBinds ¶
func (p *Producer) SetExchangeBinds(eb []*ExchangeBinds) *Producer
type PublishMsg ¶
type PublishMsg struct { ContentType string // MIME内容类型 ContentEncoding string // MIME内容编码 DeliveryMode uint8 // 暂时或持久 Priority uint8 // 0至9 Timestamp time.Time Body []byte }
PublishMsg 生产者生产的数据格式
func NewPublishMsg ¶
func NewPublishMsg(body []byte) *PublishMsg
Click to show internal directories.
Click to hide internal directories.