transfer_middleware/until/mq/consumer_config.go

33 lines
1.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package mq
import "github.com/apache/rocketmq-client-go/v2"
// ConsumerConfig 消费者配置
type ConsumerConfig struct {
TopicName string // 必填,主题名称
// GroupName 必填,消费者分组名称,填写消费的业务名称,例如:CreatePay-创建支付单
// 实际注册时,会自动在前面加上TopicName
GroupName string
// ConsumerCnt,消费者个数,默认为1,不能超过MQ的消费Queue个数
// 需要保证顺序消费的场景才推荐使用,否则推荐配置PerCoroutineCnt参数来开启并发消费即可
ConsumerCnt int
// PerCoroutineCnt 每个consumer的协程个数,默认为20,它与ConsumerCnt都能实现并发消费,区别在于此参数是一个消费者,多个协程并发消费,性能更高
// 由于是单消费者的并发处理,可能存在后拉取的比先拉取的先处理完,即无法保证严格的顺序消费要求(但大部分场景都没有顺序要求)
// SDK在收到消息时会启动一个新协程运行回调函数,最大运行协程数不超过此配置
// 示例:2,则实际的并发数是4,正常消费2个,重试2个协程
PerCoroutineCnt int
// RetryCnt 消费最大重试次数,间隔时间查看https://rocketmq.apache.org/zh/docs/featureBehavior/10consumerretrypolicy
// 我们默认为38次,目的是给异常业务方保留最多48小时去修复,超过之后进入死信队列,3天后会被自动删除
RetryCnt *int
// 指定消费的tag,为空则消费所有tag
Tags []string
//消费者实例
pushConsumers []rocketmq.PushConsumer
}