Class: MQClient

MQClient

MQ的client,用于保存aliyun账号消息,以及发送http请求


new MQClient(endpoint, accessKeyId, accessKeySecret, securityToken)

MQClient构造函数

Parameters:
Name Type Description
endpoint string

MQ的HTTP接入地址

accessKeyId string

阿里云账号的AK

accessKeySecret string

阿里云账号的SK

securityToken string

阿里云RAM授权的STS TOKEN,可空

Source:
Returns:
Type
MQClient

Methods


buildHeaders(method, body, resource)

组装请求MQ需要的请求头

Parameters:
Name Type Description
method string

请求方法

body string

请求内容

resource string

HTTP请求URL的path

Source:
Returns:

headers

Type
object

delete(resource, type, requestBody)

发送HTTP DELETE请求

Parameters:
Name Type Description
resource string

HTTP请求URL的path

type string

解析XML响应内容的元素名字

requestBody string

请求的body

Source:
Returns:
{
 code: 200,
 requestId: "xxxxxxxxxxxxxx",
 body: {A:1,B:2,C:3}
}
Type
object

get(resource, type, opts)

发送HTTP GET请求

Parameters:
Name Type Description
resource string

HTTP请求URL的path

type string

解析XML响应内容的元素名字

opts object

额外请求的参数

Source:
Returns:
{
 code: 200,
 requestId: "xxxxxxxxxxxxxx",
 body: {A:1,B:2,C:3}
}
Type
object

getConsumer(instanceId, topic, consumer, messageTag)

构造一个MQ的消费者

Parameters:
Name Type Description
instanceId string

实例ID

topic string

主题名字

consumer string

消费者名字

messageTag string

消费的过滤标签,可空

Source:
Returns:
Type
MQConsumer

getProducer(instanceId, topic)

构造一个MQ的生产者

Parameters:
Name Type Description
instanceId string

实例ID

topic string

主题名字

Source:
Returns:
Type
MQProducer

getTransProducer(instanceId, topic, groupId)

构造一个MQ的事务消息生产者

Parameters:
Name Type Description
instanceId string

实例ID

topic string

主题名字

groupId string

客户端GroupID

Source:
Returns:
Type
MQTransProducer

post(resource, type, requestBody)

发送HTTP POST请求

Parameters:
Name Type Description
resource string

HTTP请求URL的path

type string

解析XML响应内容的元素名字

requestBody string

请求的body

Source:
Returns:
{
 code: 200,
 requestId: "xxxxxxxxxxxxxx",
 body: {A:1,B:2,C:3}
}
Type
object

<async> request(method, resource, type, requestBody, opts)

发送http请求

Parameters:
Name Type Description
method string

HTTP的请求方法GET/PUT/POST/DELETE...

resource string

HTTP请求URL的path

type string

解析XML响应内容的元素名字

requestBody string

请求的body

opts object

额外请求的参数

Source:
Returns:
{
 code: 200,
 requestId: "xxxxxxxxxxxxxx",
 body: {A:1,B:2,C:3}
}
```json
Type
object

sign(method, headers, resource)

对请求的内容按照MQ的HTTP协议签名,sha1+base64

Parameters:
Name Type Description
method string

请求方法

headers object

请求头

resource string

HTTP请求URL的path

Source:
Returns:

签名

Type
string