1 Star 9 Fork 1

tym_hmm/rabbitmq-pool-router-path-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
BaseConsumer.go 1.26 KB
一键复制 编辑 原始数据 按行查看 历史
天蝎儿 提交于 2022-03-12 20:55 +08:00 . 兼容连接池 增加自定义Virtual Hosts
package RabbitmqRoute
import kelleyRabbimqPool "gitee.com/tym_hmm/rabbitmq-pool-go"
type BaseConsumer struct {
TaskName string
ExchangeName string
ExChangeType string
VirtualHosts string
Queue string
RouteKey string
IsTry bool //是否重试
MaxReTry int32 //最大重式次数
IsAutoAck bool //是否自动确认
}
/**
发送消息到rmq
*/
func (a *BaseConsumer) Receive(rabbitMqPool *kelleyRabbimqPool.RabbitPool, successEvent func(data []byte, header map[string]interface{}, retryClient kelleyRabbimqPool.RetryClientInterface) bool, failEvent func(code int, err error)) {
normal := &kelleyRabbimqPool.ConsumeReceive{
ExchangeName: a.ExchangeName,
ExchangeType: a.ExChangeType,
Route: a.RouteKey,
QueueName: a.Queue,
IsTry: a.IsTry,
MaxReTry: a.MaxReTry,
IsAutoAck: a.IsAutoAck,
EventFail: func(code int, e error, data []byte) {
failEvent(code, e)
return
},
EventSuccess: func(data []byte, header map[string]interface{}, retryClient kelleyRabbimqPool.RetryClientInterface) bool {
return successEvent(data, header, retryClient)
},
}
rabbitMqPool.RegisterConsumeReceive(normal)
err := rabbitMqPool.RunConsume()
if err != nil {
failEvent(CODE_RABBITMQ_RECEIVED_ERROR, err)
return
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/tym_hmm/rabbitmq-pool-router-path-go.git
git@gitee.com:tym_hmm/rabbitmq-pool-router-path-go.git
tym_hmm
rabbitmq-pool-router-path-go
rabbitmq-pool-router-path-go
master

搜索帮助