Browse Source

完成消息队列定义

yjp 4 months ago
parent
commit
e24edb0191
1 changed files with 18 additions and 0 deletions
  1. 18 0
      framework/core/infrastructure/message_queue/message_queue.go

+ 18 - 0
framework/core/infrastructure/message_queue/message_queue.go

@@ -13,6 +13,7 @@ type MessageQueue interface {
 	Subscribe(topic string, handler MessageHandler) error
 	Subscribe(topic string, handler MessageHandler) error
 	UnSubscribe(topic string) error
 	UnSubscribe(topic string) error
 	Publish(topic string, data []byte) error
 	Publish(topic string, data []byte) error
+	PublishAndWaitReply(topic string, replyTopic string, data []byte, opts ...PublishAndWaitReplyOption) ([]byte, error)
 }
 }
 
 
 // Subscribe 订阅
 // Subscribe 订阅
@@ -46,3 +47,20 @@ func UnSubscribe(messageQueue MessageQueue, topic string) error {
 func Publish(messageQueue MessageQueue, topic string, data []byte) error {
 func Publish(messageQueue MessageQueue, topic string, data []byte) error {
 	return messageQueue.Publish(topic, data)
 	return messageQueue.Publish(topic, data)
 }
 }
+
+// PublishAndWaitReply 发布消息并等待响应
+// 参数:
+// - queue: 消息队列
+// - topic: 主题
+// - data: 消息数据
+// 返回值:
+// - 响应数据
+// - 错误
+func PublishAndWaitReply(messageQueue MessageQueue, topic string, replyTopic string, data []byte, opts ...PublishAndWaitReplyOption) ([]byte, error) {
+	return messageQueue.PublishAndWaitReply(topic, replyTopic, data, opts...)
+}
+
+type PublishAndWaitReplyOption func(options *PublishAndWaitReplyOptions)
+
+type PublishAndWaitReplyOptions struct {
+}