[rabbitmq-discuss] PHP Client libraries

Alexandre Kalendarev akalend at mail.ru
Wed Feb 10 12:34:48 GMT 2010

> $cnn = new AMQPConnect (array ('port'=>5672, 'login' => 
> 'live_rabbit','password'=>'lostpassword','vhost'=>'/testhost' ));
> $exchange = new AMQPExchange($cnn);
> $queue = new AMQPQueue($cnn);
> $queue->declare('me', AMQP_AUTEDELETE | AMQP_DURABLE);
> print "new Exchange".PHP_EOL;
> $exchange->declare('ex_name','topic');
> print "declare Exchange".PHP_EOL;

> $exchange->bind('me','beta.*');

the queue "me" must be exist, else rise Exception.

> print "bind Exchange".PHP_EOL;
> $msg = "Hello World";
> $res = $exchange->publish( $msg, 'beta.me');

You could be like to use rabbit Tracer for debug.  The tracer You can find install ( unpack )  the java client library.
 rabbitmq-java-client package  include class  Tracer.

java -cp rabbitmq-client.jar:commons-io-1.2.jar:commons-cli-1.1.jar com.rabbitmq.tools.Tracer 
runjava.sh com.rabbitmq.tools.Tracer listenPort connectHost connectPort listenPort

You must have  connection on the proxy  port 5673

$cnn = new APMQConection(  array(  port=>5673 ) );

tracer output:
1257461452674: conn#74 ch#0 <- {#method<connection.start>(version-major=8,version-minor=0,server 
properties={product=RabbitMQ, platform=Erlang/OTP, information=Licensed under the MPL. See www.rabbitmq.com/, 
copyright=Copyright © 2007-2009 LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd., 
version=1.5.4},mechanisms=PLAIN AMQPLAIN,locales=en_US),null,""}
1257461452681: conn#74 ch#0 -> {#method<connection.start-ok>(client-
1257461452682: conn#74 ch#0 <- {#method<connection.tune>(channel-max=0,frame-max=131072,heartbeat=0),null,""}
etc ...

$queue = new AMQPQueue($cnn, 'Habrauser')

output trace:
1257461452685: conn#74 ch#1 -> 
1257461452686: conn#74 ch#1 <- {#method<queue.declare-ok>(queue=Habrauser,message-count=0,consumer-count=0),null,""}

By trace info You can to find the server errors. So, You can test how the work  the php-client by rabbitmqctl tools:

rabbitmqctl list_queues       // show   list queue
rabbitmqctl list_exchanges  // show  list exchanges
rabbitmqctl list_bindings     // show   list bindings

Good luke of  tracing


More information about the rabbitmq-discuss mailing list