|
@@ -13,6 +13,7 @@ type MessageQueue interface {
|
|
|
Subscribe(topic string, handler MessageHandler) error
|
|
|
UnSubscribe(topic string) error
|
|
|
Publish(topic string, data []byte) error
|
|
|
+ PublishAndWaitReply(topic string, replyTopic string, data []byte, opts ...PublishAndWaitReplyOption) ([]byte, error)
|
|
|
}
|
|
|
|
|
|
// Subscribe 订阅
|
|
@@ -46,3 +47,20 @@ func UnSubscribe(messageQueue MessageQueue, topic string) error {
|
|
|
func Publish(messageQueue MessageQueue, topic string, data []byte) error {
|
|
|
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 {
|
|
|
+}
|