简体   繁体   English

如何确定应该使用哪种套接字从RabbitMQ队列中获取消息?

[英]How can I determine what sort of socket I should use to get messages from a RabbitMQ queue?

I'm using Rabbit.js to connect to a queue on a remote server. 我正在使用Rabbit.js连接到远程服务器上的队列。 The issue is that every time I try to connect I get: 问题是,每次尝试连接时,都会得到:

Error: Channel closed by server: 406 (PRECONDITION-FAILED) with message 
  "PRECONDITION_FAILED - inequivalent arg 'durable' for exchange 'WorkOrderQuery.Response' in vhost '/': received 'false' but current is 'true'"
  at Channel.C.accept (/Users/collumj/work/alpha/node_modules/rabbit.js/node_modules/amqplib/lib/channel.js:398:24)
  at Connection.mainAccept [as accept] (/Users/collumj/work/alpha/node_modules/rabbit.js/node_modules/amqplib/lib/connection.js:63:33)

I can provide code if needed. 如果需要,我可以提供代码。 I've tried passing an options object with durable: true at relevant points to no effect. 我尝试过传递带有durable: true的options对象durable: true在相关点为durable: true无效。 Everything is firing off in the correct order but I am always getting the error about the durable value being set wrong. 一切都以正确的顺序进行,但是我总是会遇到关于持久值设置错误的错误。

The question is: how do I look at a queue's page on the RabbitMQ server and determine what sort of socket I should use to connect to it? 问题是:如何查看RabbitMQ服务器上的队列页面并确定应使用哪种套接字连接? I can try a few but trying things blindly isn't a great way to go so I'd rather know that I'm using the right type. 我可以尝试一些方法,但是盲目尝试并不是一个好方法,所以我很想知道我使用的是正确的类型。

It's possible that these two things have nothing to do with each other. 这两件事可能彼此无关。 If so, I'd appreciate an explanation because I'm clearly missing it. 如果是这样,我将不胜感激。

Here's an image of my RabbitMQ Queue page: 这是我的RabbitMQ队列页面的图像:

在此处输入图片说明

Edit: changing my SUBSCRIBE socket to a PULL socket fixed it. 编辑:将我的SUBSCRIBE套接字更改为PULL套接字,将其固定。 Still not sure how I would have known (or if) from looking at the queue's page. 仍然不确定通过查看队列页面如何知道(或是否知道)。

I don't know what's behind the abstraction your library is using but the error message: 我不知道您的库使用的抽象背后是什么,但是出现错误消息:

"PRECONDITION_FAILED - inequivalent arg 'durable' for exchange 'WorkOrderQuery.Response' in vhost '/': received 'false' but current is 'true'" “ PRECONDITION_FAILED-虚拟主机'/'中用于交换'WorkOrderQuery.Response'的等价arg'持久':收到'false'但当前为'true'”

Means that at some point your program declared an exchange as durable, but then tried to re-declare it as non-durable. 意味着您的程序在某个时候将交换声明为持久性,但随后尝试将其重新声明为非持久性。

In RabbitMQ, whenever you re-declare exchanges or queues, you have to use the same arguments that where used when the resource was created 在RabbitMQ中,每当您重新声明交换或队列时,都必须使用与创建资源时相同的参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM