소스 검색

update

tags/v0.0.4
DengBiao 1 년 전
부모
커밋
2d64ccb092
2개의 변경된 파일8개의 추가작업 그리고 8개의 파일을 삭제
  1. +7
    -7
      rabbit/pool.go
  2. +1
    -1
      test/single_queue_test.go

+ 7
- 7
rabbit/pool.go 파일 보기

@@ -401,14 +401,14 @@ func (ch *Channel) Publish(exchange string, body interface{}, key string) {
}

// 接收某个消息队列的消息
func (ch *Channel) Consume(name string) <-chan amqp.Delivery {
func (ch *Channel) Consume(name string, autoAck bool) <-chan amqp.Delivery {
c, e := ch.Channel.Consume(
name, // 指定从哪个队列中接收消息
"", // 用来区分多个消费者
false, // 是否自动应答
false, // 是否独有
false, // 如果设置为true,表示不能将同一个connection中发送的消息传递给这个connection中的消费者
false, // 列是否阻塞
name, // 指定从哪个队列中接收消息
"", // 用来区分多个消费者
autoAck, // 是否自动应答
false, // 是否独有
false, // 如果设置为true,表示不能将同一个connection中发送的消息传递给这个connection中的消费者
false, // 列是否阻塞
nil,
)
failOnError(e, "接收消息失败!")


+ 1
- 1
test/single_queue_test.go 파일 보기

@@ -98,7 +98,7 @@ func TestReceive1(t *testing.T) {

defer ch.Release()
ch.Qos(5)
delivery := ch.Consume(SingleQueueName)
delivery := ch.Consume(SingleQueueName, false)

var res amqp.Delivery
var ok bool


불러오는 중...
취소
저장