CNode

阿里云MQS nodejs SDK

分享
Vvfasky发布于12 年前最后回复12 年前3 回复5834 浏览0 收藏

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)

A
alsotang#1·12 年前

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

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

H
hainee#3·12 年前

顶一个

参与回复
登录后即可参与回复。登录