瀏覽代碼

update

tags/v0.0.5
DengBiao 3 月之前
父節點
當前提交
1705a83fd1
共有 1 個檔案被更改,包括 21 行新增0 行删除
  1. +21
    -0
      rabbit/pool.go

+ 21
- 0
rabbit/pool.go 查看文件

@@ -400,6 +400,27 @@ func (ch *Channel) Publish(exchange string, body interface{}, key string) {
failOnError(e, "向路由发送消息失败!")
}

// PublishV2 向exchange发送消息
// 可以往某个exchange发送消息
func (ch *Channel) PublishV2(exchange string, body interface{}, key string) error {
str, e := json.Marshal(body)
if e != nil {
return e
}
e = ch.Channel.Publish(
exchange,
key,
false,
false,
amqp.Publishing{
ContentType: "text/plain",
DeliveryMode: amqp.Transient,
Priority: 0,
Body: []byte(str)},
)
return e
}

// 接收某个消息队列的消息
func (ch *Channel) Consume(name string, autoAck bool) <-chan amqp.Delivery {
c, e := ch.Channel.Consume(


Loading…
取消
儲存