new MQProducer(client, instanceId, topic)
构造函数
Parameters:
Name | Type | Description |
---|---|---|
client |
MQClient | MQ的客户端 |
instanceId |
string | 实例ID |
topic |
string | 主题名字 |
Returns:
- Type
- MQProducer
Methods
-
<async> publishMessage(body, tag, msgProps)
-
向主题发送一条消息
Parameters:
Name Type Description body
string 发送的内容
tag
string 发送消息的标签
msgProps
MessageProperties 发送消息的属性
Throws:
-
err MQ服务端返回的错误或者其它网络异常
{ // MQ服务端返回的错误Code,like: TopicNotExist Code:"", // 请求ID RequestId:"" }
- Type
- exception
Returns:
{ // http请求状态码,发送成功就是201,如果发送失败则抛异常 code: 201, // 请求ID requestId: "xxxxxxxxxxxxxx", // 发送消息的响应内容 body: { // 消息ID MessageId: "", // 消息体内容的MD5值 MessageBodyMD5: "" } }
- Type
- object
-