开发者

Retrieve messages from RabbitMQ queue(s)

开发者 https://www.devze.com 2022-12-19 04:24 出处:网络
I\'m looking to implement RabbitMQ into my PHP application, and am using the php-amqp extension. My only question is th开发者_运维知识库is, how do I easily query to return the contents of the queue in

I'm looking to implement RabbitMQ into my PHP application, and am using the php-amqp extension. My only question is th开发者_运维知识库is, how do I easily query to return the contents of the queue in PHP?

php-amqp seems to not enable me to do this. If I am going wrong, please help me out here :)


James, could you please ask this question on rabbitmq-discuss? Your question touches on what it means to 'query' a queue in order to get messages. In RabbitMQ you consume messages from queues, and perform filtering using queue bindings. Have a look at this intro - http://blogs.digitar.com/jjww/2009/01/rabbits-and-warrens/

Cheers

alexis RabbitMQ


If you need to know how many messages are in a queue, you can get this information when you declare the queue, or if you use basic.get to retrieve a single message. Normally, recipients of messages will use basic.consume and they will not know how many messages are waiting.


Such kind of question are more about queue data type and general AMQP concept.

In AMQP (and in RabbitMQ, which is AMQP-compatible broker) queues are typical FIFO queues. Queue is not that type of data types that normally used for arbitrary items access and RabbitMQ at this time doesn't provide any way to bypass FIFO concept and allow such kind of access. At least out of the box. There are might be any third-party plugins, but I'm not aware of any such of a kind. And once again, it will ruin whole FIFO concept and it just become some new redis or whatever, not even talking about performance impact (one can check complexity of common data structures operation, even this Q&A on SO - What are the time complexities of various data structures? gives brief idea why adding arbitrary access is not a goal of AMQP or any AMQP-compatible broker that cares about performance).

Most of questions about arbitrary queue access comes when queues are put into wrong context: it might be a case when queue concept just doesn't fit current or desire architecture and when some key-value storage or database fist better.

0

精彩评论

暂无评论...
验证码 换一张
取 消