阿里云MQS nodejs SDK
发布于 10 年前 作者 vfasky 4552 次浏览 最后一次编辑是 8 年前 来自 分享

github https://github.com/vfasky/node_aliyun_mqs_sdk

demo

var MQSClient = require('aliyun_mqs');

var client = new MQSClient({
    accessKeyId: 'you accessKeyId',
    accessKeySecret: 'you accessKeySecret',
    url: 'http://{you}.aliyuncs.com'
});

//创建队列
client.queue.create('test', {}, function(err, url){
    if(!err){
        //发消息
        client.message.send('test', {
            msg: 'test'
        }, function(err, data){
            console.log(data);
        });
    }
});
3 回复

我乱说几句哈。 client.queue.create('test', {}) 应该有返回值,返回一个代表队列的对象,比如 var testQueue

然后我们可以调用 testQueue.send(msgObject, callback)send 方法应该是向一个自身的队列压入 msgObject,如果队列已经连接好了,那么直接 执行;如果队列没连接好,就等待连接,当连接完成的事件触发,再一次性全部 send 出去。

@alsotang 好主意!

回到顶部