cmq-sdk

CMQ 消息队列 NODE SDK

Usage no npm install needed!

<script type="module">
  import cmqSdk from 'https://cdn.skypack.dev/cmq-sdk';
</script>

README

CMQ NODE SDK

CMQ 消息队列 NODE SDK

npm Travis (.org) Coveralls github node Downloads TypeScript GitHub license

安装

npm install cmq-sdk --save

创建客户端

import { CMQ } from 'cmq-sdk';

const cmq = CMQ.NEW({
    path: '/v2/index.php',
    signatureMethod: 'HmacSHA256',
    extranet: true,
    secretId: '<secretId>',
    secretKey: '<secretKey>',
    region: 'gz'
});
  • path string 云 API 的请求固定路径,当前固定为 /v2/index.php
  • signatureMethod string 加密方式,目前支持 HmacSHA256HmacSHA1
  • extranet boolean 是否为公网,用来决定请求地址
  • secretId string 云API密钥 SecretId
  • secretKey string 云API密钥 SecretKey
  • region string 地域参数,例如:gz(广州)、sh(上海)...

创建好客户端即可操作使用,例如:创建一个 test 队列

client.createQueue({
    queueName: 'test'
}).then(response => {
    // response
});

// Or use async/await
try{
    const response = await client.createQueue({
        queueName: 'test'
    });
} catch (e) {
    // error
}