免费观看又色又爽又黄的小说免费_美女福利视频国产片_亚洲欧美精品_美国一级大黄大色毛片

node.js中怎么對CQS進行操作

本篇文章為大家展示了node.js中怎么對CQS進行操作,內容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。

創新互聯公司提供成都網站建設、網站建設、網頁設計,品牌網站設計一元廣告等致力于企業網站建設與公司網站制作,10多年的網站開發和建站經驗,助力企業信息化建設,成功案例突破上千余家,是您實現網站建設的好選擇.

怎樣使用node.js來操作CQS

安裝:

$npminstallcqs

初始化你的CQS模塊:

//Anormalimport.

varcqs=require('cqs');

//Pre-applymycouchanddbname.

cqs=cqs.defaults({"couch":"https://user:password@example.iriscouch.com"

,"db":"cqs_queue"

});

列出所有的隊列:

cqs.ListQueues(function(error,queues){

console.log("Found"+queues.length+"queues:");

queues.forEach(function(queue){

console.log("*"+queue.name);

})

//Output:

//Found2queues:

//*a_queue

//*another_queue

})

創建一個隊列:

//Justcreatewithaname.

cqs.CreateQueue("important_stuff",function(error,queue){

if(!error)

console.log("Importantstuffqueueisready");

})

//Createwithanoptionsobject.

varopts={QueueName:"unimportant_stuff"

,DefaultVisibilityTimeout:3600//1hour

};

cqs.CreateQueue(opts,function(error,queue){

if(!error)

console.log("Created"+queue.name+"withtimeout+"queue.VisibilityTimeout);

//Output

//Createdunimportant_stuffwithtimeout3600

})

怎樣使用node.js來操作CQS

添加一個隊列消息:

//TheconvenientobjectAPI:

important_stuff.send(["keepthese","things","inorder"],function(error,message){

if(!error)

console.log('Sent:'+JSON.stringify(message.Body));

//Output:

//Sent:["keepthese","things","inorder"]

})

cqs.SendMessage(important_stuff,"Thismessageisimportant!",function(error,message){

if(!error)

console.log('Sentmessage:'+message.Body);

//Output:

//Sentmessage:Thismessageisimportant!

})

//Or,justusethequeuename.

cqs.SendMessage('some_other_queue',{going_to:"theotherqueue"},function(error,message){

if(!error)

console.log('Message'+message.MessageId+'isgoingto'+message.Body.going_to);

//Output:

//Messagea9b1c48bd6ae433eb7879013332cd3cdisgoingtotheotherqueue

})

接收并處理一條隊列消息:

//TheconvenientobjectAPI:

my_queue.receive(function(error,messages){

if(!error)

console.log('Receivedmessage:'+JSON.stringify(messages[0].Body));

//Output:

//Receivedmessage:

})

//ThestandardAPI,receivingmultiplemessages

cqs.ReceiveMessage(some_queue,5,function(er,messages){

if(!error)

console.log('Received'+messages.length+'messages');

//Output:

//Received<0through6>messages

})

刪除一條隊列消息:

//TheconvenientobjectAPI:

message.del(function(error){

//Messagedeletionneverresultsinanerror.Ifamessageissuccessfully

//deleted,itwillsimplyneverappearinthequeueagain.

console.log('Messagedeleted!');

})

//ThestandardAPI:

cqs.DeleteMessage(my_message,function(error){

console.log('Messagedeleted');

})

上述內容就是node.js中怎么對CQS進行操作,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注創新互聯行業資訊頻道。

新聞標題:node.js中怎么對CQS進行操作
本文來源:http://m.newbst.com/article26/jeepcg.html

成都網站建設公司_創新互聯,為您提供小程序開發App開發建站公司Google網站設計公司品牌網站建設

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

搜索引擎優化