-
Notifications
You must be signed in to change notification settings - Fork 0
/
consumer_test.go
44 lines (42 loc) · 1.03 KB
/
consumer_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package rmq
import (
"testing"
)
func TestConsumer(t *testing.T) {
//conf := &RocketMQConfig{
// Namespace: "MQ_INST_xxx",
// GroupName: "GID_xxx",
// EndPoint: "http://xxx.cn-hangzhou.mq-internal.aliyuncs.com:8080",
// AccessKey: "xxx",
// SecretKey: "xxx",
// LogLevel: LogError,
// // 自定义配置
// //ConsumerOptions: []consumer.Option{
// // consumer.WithMaxReconsumeTimes(10),
// // consumer.WithConsumeMessageBatchMaxSize(1),
// // consumer.WithPullInterval(time.Millisecond),
// // consumer.WithPullBatchSize(10),
// // consumer.WithConsumerModel(consumer.BroadCasting),
// //},
//}
//conn, err := NewConsumer(conf).Conn()
//if err != nil {
// xlog.Error(err)
// return
//}
//defer conn.Close()
//
//if err = conn.SubscribeSingle("topic", "*", func(c context.Context, ext *primitive.MessageExt) error {
// xlog.Debugf("body:%v", string(ext.Body))
// return nil
//}); err != nil {
// xlog.Error(err)
// return
//}
//
//if err = conn.Start(); err != nil {
// xlog.Error(err)
//}
//
//time.Sleep(time.Hour)
}