在线精品99_中国九九盗摄偷拍偷看_91免费版在线观看_91.app_91高清视频在线_99热最新网站

node.js中怎么对CQS进行操作

144次阅读
没有评论

共计 2288 个字符,预计需要花费 6 分钟才能阅读完成。

自动写代码机器人,免费开通

本篇文章为大家展示了 node.js 中怎么对 CQS 进行操作,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

怎样使用 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 进行操作,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注丸趣 TV 行业资讯频道。

向 AI 问一下细节

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-12-04发表,共计2288字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)
主站蜘蛛池模板: 老汉影视永久免费视频 | 日本黄大片视频在线播放 | av中文字幕潮喷人妻系列 | 18禁无遮拦无码国产在线播放 | 免费看午夜高清性色生活片 | 九九色在线视频 | 久久免费观看国产99精品 | 高清性做爰免费网站 | 尤物视频免费在线观看 | 国产一区二区波多野结衣 | 国产三级久久久精品麻豆三级 | 最好看2019高清中文字幕视频 | 八戒久久精品一区二区三区 | 久久亚洲av成人出白浆无码国产 | 一本色道久久综合亚洲精品不卡 | 欧美gv在线观看 | 四虎影院最新网站 | 亚洲精品一区 | 亚洲av无码欧洲av无码网站 | 亚洲欧美日韩高清一区二区一 | 人人爽人人澡人人高潮 | 日本在线精品视频 | 国产成人亚洲综合91精品555 | www.四虎影院.con| 久久青青草原精品老司机 | 色妞色视频一区二区三区四区 | 尹人成人 | 国产 麻豆| 免费黄色大片网站 | 大肉大捧一进一出视频 | 中文在线中文资源 | a天堂视频 | www成年人 | 中文字幕无线码中文字幕免费 | 精品视频入口 | 三级网站视频 | 拍摄av现场失控高潮数次 | 亚洲熟女乱综合一区二区 | 最新91精品老司机在线 | 久久国产精品视频 | 欧美一区二区三区视频 |