English 中文(简体)
Retrieve messages from RabbitMQ queue(s)
原标题:

I m looking to implement RabbitMQ into my PHP application, and am using the php-amqp extension. My only question is this, 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.





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签