Pārlūkot izejas kodu

update

tags/v0.0.5
DengBiao pirms 10 mēnešiem
vecāks
revīzija
1705a83fd1
1 mainītis faili ar 21 papildinājumiem un 0 dzēšanām
  1. +21
    -0
      rabbit/pool.go

+ 21
- 0
rabbit/pool.go Parādīt failu

@@ -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(


Notiek ielāde…
Atcelt
Saglabāt