1 Star 0 Fork 0

天雨流芳 / go-micro-framework

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
mq.go 1.93 KB
一键复制 编辑 原始数据 按行查看 历史
天雨流芳 提交于 2024-04-07 17:27 . 修改mq的包位置
package mq
import (
"context"
"github.com/apache/rocketmq-client-go/v2/primitive"
)
// Producer 普通消息的发送接口
type Producer interface {
ProducerStart() error // 开启生产者Client
ProducerStop() error // 结束生产者Client
// MessageSync 同步发送(Synchronous):这是最常见的一种发送方式,客户端发送消息后,会等待服务器端的响应。
// 只有当消息完全被服务器接收,客户端才会继续执行。这种方式适用于对可靠性要求较高的场景。
MessageSync(topic string, data []byte) error
// MessageSyncDelayTime 用同步的方式发送延迟消息
MessageSyncDelayTime(topic string, data []byte, delayTimeLevel int) error
// MessageAsync 异步发送(Asynchronous):客户端在发送消息后不会立即等待服务器的响应,而是通过一个回调接口来处理服务器的响应,
// 这样可以提高消息发送的吞吐量。这种方式适用于对响应时间要求较敏感的场景。
MessageAsync(topic string, data []byte, callback func(ctx context.Context, result *primitive.SendResult, err error)) error // 发送异步消息
// MessageOneWay 单向发送(One-way):这种方式是最轻量级的一种发送方式,客户端只负责发送消息,
// 不等待服务器的响应,也不关心消息是否被服务器接收。这种方式的可靠性最低,但吞吐量最高,适用于对可靠性要求不高的日志收集等场景。
MessageOneWay(topic string, data []byte) error // 发送异步消息
}
// TransactionProducer 事务消息的发送接口
type TransactionProducer interface {
ProducerStart() error // 开启生产者Client
ProducerStop() error
// MessageInTransaction 发送事务消息
MessageInTransaction(topic string, data []byte) error
}
type Consumer interface {
Subscribe() error // 订阅消息
ConsumerStart() error // 开启消费者Client
ConsumerStop() error // 结束消费者Client
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tylf2018/go-micro-framework.git
git@gitee.com:tylf2018/go-micro-framework.git
tylf2018
go-micro-framework
go-micro-framework
4cc90ded505a

搜索帮助

344bd9b3 5694891 D2dac590 5694891