[rabbitmq-discuss] PHP Client libraries

Pieter de Zwart pdezwart at rubiconproject.com
Tue Feb 9 19:20:29 GMT 2010


Good news. Seems like have a mostly working php-rabbit PHP module. Attached
is the patch to make it work with RabbitMQ 1.7*. For those of you less
familiar with building/managing PHP clients, perform the following commands:

$ wget http://php-rabbit.googlecode.com/files/php-rabbit.zip
$ unzip php-rabbit.zip
$ cd php-rabbit
$ phpize
$ php ­I | head
Copy the current ./configure statement and execute it
$ patch rabbit.c php-rabbit.patch
$ make && sudo make install
$ echo ³extension = /path/to/lib/folder/rabbit.so² > /etc/php.d/rabbit.ini
$ php ­m | grep rabbit
The last command should display ³rabbit², meaning that the library was
recognized.

I have also included a very basic test script that you can use to validate
that things are working. I tweaked it post test, so there might be some
typos in it.

I had to run:
$ sudo /sbin/ldconfig
to get the librabbitmq.so library to be pulled in, so please keep that in
mind.

If you have any questions, please let me know. There are still a few bugs,
two of which are:
1. During connection, if you specify additional parameters like
AMQP_DURABLE, the exchange type length is seen as 0, even if you specify
one, and it therefore defaults all new exchange types to Œdirect¹. We use
topic exchanges here, so I tweaked it to default to Œtopic¹ until that gets
fixed. 
2. I managed to make it segfault by passing in a weird exchange name. I will
put together a demonstration script asap.

This patch fixes:
1. Names and typos. Everything is AMQP (not AQPM, etc..) and the connection
class is AMQPConnection, not AQMPConnect.
2. The library is now defined correctly, and should therefore load without
tweaking the configure or doing any other wonky things.
3. All of the METHOD_OK parameters are no longer dereferenced improperly
4. I added the heartbeat parameter to provide the valid number of parameters
to amqp_login

I am now going to go load test this thing to see if I can make it crash.

Pieter


On 2/9/10 8:47 AM, "Pieter de Zwart" <pdezwart at rubiconproject.com> wrote:

> Hey guys,
> 
> Just FYI, I have a mostly working php-rabbit patch. Using the demo script I
> can declare, bind, publish and consume. I ran into a segfault when I tried to
> incorporate it into our framework, so there is still some debugging to do
> there.
> I will submit a patch to everyone later today, with the understanding that I
> make no guarantees as to whether it is production ready.
> 
> Pieter
> 
> 
> On 2/9/10 3:00 AM, "Alexandre Kalendarev" <akalend at mail.ru> wrote:
> 
>> Hi Dieter,
>> 
>>> > thank you for your reply. Am I right, the module does not support
>>> > consuming messages?
>> 
>> The module is support Consume and Get methods. But Consume
>> methods is sync and GET is async.
>> 
>> If You use the  the consume in the WEB pages, the HTTP protocol is async and
>> You can't wait if you have not commet technology.
>> My recomendation  is use the series of GET method:
>> 
>> // get queue items
>> $queue = new AMQPQueue(APMQConection(), 'my_queue');
>> $i=0;
>> $res = true;
>> while ($res = $queue->get() !== false  ){
>>     $i++;
>>     echo "$i : {$res['msg']}<br>\n";
>> }
>> 
>> But, You can use the Consume, You must the read queue lenght and make Consume
>> of len messages.
>> It is guarantie of absent waiting new messages.
>> 
>> 
>> // consume
>> $i=0;
>> $queue = new AMQPQueue(APMQConection());
>> 
>> $n = $queue->declare('my_queue');  // we get the lenght of queue
>>   
>> $queueMessages = $queue->consume( $n ); // we reading $n messages,  all
>> queue.
>> foreach($queueMessages as $item){
>>   $i++;
>>   echo "$i.$item";
>> }
>> 
>> If $n less lenght of queue, the all nonreaded messages will be gone.
>> 
>> The Consume method is faster.
>> 
>>> >Or Am i mixing up the Modules?
>> the module php-amqp  http://code.google.com/p/php-amqp/   don't support
>> consume, bind and queue. It is only publish.
>> 
>> If You have any questions send me, I will very happeness ask You. Sorry for
>> my English.
>> 
>> Alexandre
>> 
>> _______________________________________________
>> rabbitmq-discuss mailing list
>> rabbitmq-discuss at lists.rabbitmq.com
>> http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>> 

-- 
the rubicon project

PIETER DE ZWART | INTERFACES ENGINEER

€€€ P 310 207 0272 | x224
€€€ F 323 466 7119


1925 S. BUNDY  DRIVE
LOS ANGELES, CALIFORNIA 90025

WWW.RUBICONPROJECT.COM <http://www.rubiconproject.com/>


³COMPANY OF THE YEAR² ALWAYSON ONMEDIA 2009
#24 ON FAST COMPANY FAST 50 READER FAVORITES
2008  ALWAYSON 250 GLOBAL WINNER
2008 ALWAYSON ONMEDIA 100 WINNER
TWIISTUP3  BEST IN SHOW
PRICEWATERHOUSECOOPERS ­ ENTRETECH  BEST STARTUP
AMERICAN BUSINESS AWARDS - STEVIES  Œ08 FINALIST BEST NEW COMPANY
AMERICAN BUSINESS  AWARDS - STEVIES Œ08 FINALIST MOST INNOVATIVE COMPANY
AMERICAN BUSINESS  AWARDS - STEVIES Œ08 FINALIST NEW PRODUCT OR SERVICE -
SERVICES

P          Please consider the environment before printing this e-mail

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20100209/655aa139/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 28320 bytes
Desc: not available
Url : http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20100209/655aa139/attachment.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: php-rabbit.patch
Type: application/octet-stream
Size: 5660 bytes
Desc: not available
Url : http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20100209/655aa139/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-rabbit.php
Type: application/octet-stream
Size: 770 bytes
Desc: not available
Url : http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20100209/655aa139/attachment-0001.obj 


More information about the rabbitmq-discuss mailing list