为什么 Perl 的 RabbitMQ 使用者会收到 404 错误?
RabbitMQ 已设置,我可以使用示例脚本:
use Net::RabbitMQ;
my $mq = Net::RabbitMQ->new();
$mq->connect("localhost", { user => "guest", password => "guest" });
$mq->channel_open(1);
$mq->publish(1, "queuename", "Hi there!");
$mq->disconnect();
它发布消息(我假设)。我尝试了以下方法来简单地从队列中获取消息,但得到了 404:
my $mq = Net::RabbitMQ->new();
$mq->connect("localhost", { user => "guest", password => "guest" });
$mq->channel_open(1);
print $mq->get(1, "queuename");
RabbitMQ is setup and I can use the sample script:
use Net::RabbitMQ;
my $mq = Net::RabbitMQ->new();
$mq->connect("localhost", { user => "guest", password => "guest" });
$mq->channel_open(1);
$mq->publish(1, "queuename", "Hi there!");
$mq->disconnect();
It posts messages (I assume). I tried the following for a simple grab of a message off of the queue and I get a 404:
my $mq = Net::RabbitMQ->new();
$mq->connect("localhost", { user => "guest", password => "guest" });
$mq->channel_open(1);
print $mq->get(1, "queuename");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
错误消息全文为:
You need to create the queue with
auto_delete =>; 0
- 否则当第一个进程终止时它将消失。看一下queue_declare
方法。The full text of the error message is:
You need to create the queue with
auto_delete => 0
- otherwise it will go away when the first process terminates. Have a look at thequeue_declare
method.我查看了
queue_declare
并将其添加到侦听器中,并更改了一些代码,如下所示:我关闭侦听器脚本,然后,当我执行以下命令时,它会发布消息:
I looked at
queue_declare
and added it to the listener and changed some code as follows:I kick the listener script off, then, when I execute the following, it posts messages: