await/async:assertQueue([queue, [options]])
callback:assertQueue([queue, [options, [function(err, ok) {…}]]])
- queue:队列名称
- options:队列参数,可谓空(null)
- exclusive-[type:bool]-[detail:false]-[info:将队列范围定义为链接]
- durable-[type:bool]-[detail:false]-[info:定义队列是否持久化,重启之后是否依然存在]
- autoDelete-[type:bool]-[detail:true]-[info:当队列为空,自动删除队列]
- messageTtl-[type:num]-[info:n毫秒后,到达队列的消息为过期消息,0<=n<2^32]
- expires-[type:num]-[info:队列n毫秒后,不被销毁,0<=n<2^32]
- deadLetterExchange-[type:string]-[info:队列中丢弃的消息,将发送到该交换]
- deadLetterRoutingKey-???
- maxLength-[type:num]-[info:最大消息队列,旧消息将被丢弃]
- maxPriority-[type:num]-[info:这是优先队列]
- arguments-[info:附加参数,为RabbitMQ插件试用]
```javascript // await/async try{ const assertQueue = await channel.assertQueue(queue,{ exclusive: “[type:bool]-[detail:false]-[info:将队列范围定义为链接]”, durable: “[type:bool]-[detail:false]-[info:定义队列是否持久化,重启之后是否依然存在]”, autoDelete: “[type:bool]-[detail:true]-[info:当队列为空,自动删除队列]”, messageTtl: “[type:num]-[info:n毫秒后,到达队列的消息为过期消息,0<=n<2^32]”, expires: “[type:num]-[info:队列n毫秒后,不被销毁,0<=n<2^32]”, deadLetterExchange: “[type:string]-[info:队列中丢弃的消息,将发送到该交换]”, deadLetterRoutingKey: “???”, maxLength: “[type:num]-[info:最大消息队列,旧消息将被丢弃]”, maxPriority: “[type:num]-[info:这是优先队列]”, arguments: “[info:附加参数,为RabbitMQ插件试用]”, }; console.log(assertQueue) /**// callback
channel.assertQueue(queue,{
exclusive: "[type:bool]-[detail:false]-[info:将队列范围定义为链接]",
durable: "[type:bool]-[detail:false]-[info:定义队列是否持久化,重启之后是否依然存在]",
autoDelete: "[type:bool]-[detail:true]-[info:当队列为空,自动删除队列]",
messageTtl: "[type:num]-[info:n毫秒后,到达队列的消息为过期消息,0<=n<2^32]",
expires: "[type:num]-[info:队列n毫秒后,不被销毁,0<=n<2^32]",
deadLetterExchange: "[type:string]-[info:队列中丢弃的消息,将发送到该交换]",
deadLetterRoutingKey: "???",
maxLength: "[type:num]-[info:最大消息队列,旧消息将被丢弃]",
maxPriority: "[type:num]-[info:这是优先队列]",
arguments: "[info:附加参数,为RabbitMQ插件试用]",
},function(error,ok){
if(error) throw error;
console.log(ok)
})
- log :
- {
- queue: ‘foobar’, 队列名
- messageCount: 0, 消费者计数
- consumerCount: 0, 最近的消息计数
- } */ }catch(e){ console.log(e); } ```