问题描述
作为学习RabbitMQ和python的一种方式,我正在开发一个项目,该项目使我可以在多台计算机之间分发h264编码.基本操作已经完成,我有一个可在Linux或Mac上运行的守护程序,该守护程序可附加到队列,接受作业并使用HandBrakeCLI对其进行编码,并在编码完成后回复消息.我还构建了一个简单的工具来将项目推送到队列中.
As a way to learn RabbitMQ and python I'm working on a project that allows me to distribute h264 encodes between a number of computers. The basics are done, I have a daemon that runs on Linux or Mac that attaches to queue, accepts jobs and encodes them using HandBrakeCLI and acks the message once the encode is complete. I've also built a simple tool to push items into the queue.
现在,我想扩展将项目推入队列的工具的功能,以便可以查看队列中的内容.我知道能够查看队列中有多少项目,但是我希望能够获取实际的消息,以便可以显示正在等待编码的电影或电视节目.想法是,队列管理器将在作业完成时从编码器客户端接收消息,然后刷新队列列表.
Now I want to expand the capabilities of the tool that pushes items into the queue so that I can view what is in the queue. I'm aware of the ability to see how many items are in the queue, but I want to be able to get the actual messages so I can show what movie or TV show is waiting to be encoded yet. The idea is that the queue manager would receive messages from the encoder clients when a job has completed and then refresh the queue list.
我知道有一种使队列管理器的列表与实际工作队列保持同步的复杂方法,但是我希望它是持久的",因为我应该能够关闭队列管理器并在以后重新打开它查看队列.
I know there is a convoluted way of keeping the queue manager's list in sync with the actual work queue but I'd like this to be "persistent" in that I should be able to close the queue manager and reopen it later to see the queue.
推荐答案
不直接支持队列浏览,但是如果您声明一个没有自动确认的队列并且不对收到的消息进行ACK,那么您可以看到所有内容它.查看后,在通道上发送CANCEL,或断开连接并重新连接,以使所有消息重新排队.这确实会增加邮件标题中的数字,但不影响邮件.
Queue browsing is not supported directly, but if you declare a queue with NO auto acknowledgements and do not ACK the messages that you receive, then you can see everything in it. After you have had a look, send a CANCEL on the channel, or disconnect and reconnect to cause all the messages to be requeued. This does increment a number in the message headers, but otherwise leaves the messages untouched.
我构建了一个应用,在该应用中,消息排序并不十分重要,并且我经常以这种方式扫描队列.如果发现问题,我会将消息转储到文件中,进行修复并重新提交.
I built an app where message ordering was not terribly important, and I frequently scanned through the queue in this way. If I found a problem, I would dump the messages into a file, fix them and resubmit.
如果您只需要偶尔查看一则或两则消息,则可以使用RabbitMQ管理插件.
If you only need to peek at a message or two once in a while you can do that with the RabbitMQ management plugin.
此外,如果只需要消息计数,则可以在每次声明队列时或在basic.get命令上获得该消息.
In addition, if you only need a message count, you can get that every time you declare the queue, or on a basic.get command.
这篇关于使用RabbitMQ是否可以在不进行出队操作的情况下查看队列内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!