|
|
@ -1,6 +1,8 @@ |
|
|
|
package rocketmq |
|
|
|
|
|
|
|
import ( |
|
|
|
"context" |
|
|
|
"errors" |
|
|
|
"github.com/apache/rocketmq-client-go/v2" |
|
|
|
"github.com/apache/rocketmq-client-go/v2/primitive" |
|
|
|
"github.com/apache/rocketmq-client-go/v2/producer" |
|
|
@ -26,3 +28,10 @@ func MqConnect(group string, resolver []string) { |
|
|
|
} |
|
|
|
MqPool = p |
|
|
|
} |
|
|
|
func SendSync(ctx context.Context, mq *primitive.Message) (*primitive.SendResult, error) { |
|
|
|
var res primitive.SendResult |
|
|
|
if MqPool == nil { |
|
|
|
return &res, errors.New("Mq未链接") |
|
|
|
} |
|
|
|
return MqPool.SendSync(ctx, mq) |
|
|
|
} |