php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #61589
Patch amqp_example.patch revision 2012-04-01 07:01 UTC by gwijaya at gmail dot com

Patch amqp_example.patch for amqp Bug #61589

Patch version 2012-04-01 07:01 UTC

Return to Bug #61589 | Download this patch
Patch Revisions:

Developer: gwijaya@gmail.com

diff --git a/testpub.php b/testpub2.php
index 105c4eb..0c7a41e 100644
--- a/testpub.php
+++ b/testpub2.php
@@ -6,13 +6,19 @@ $cnn->connect();
 $ch = new AMQPChannel($cnn);
 // Declare a new exchange
 $ex = new AMQPExchange($ch);
-$ex->declare('exchange1', AMQP_EX_TYPE_FANOUT);
+$ex->setName('exchange1');
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declare();
 // Create a new queue
 $q = new AMQPQueue($ch);
-$q->declare('queue1');
+$q->setName('queue1');
+$q->declare();
 // Bind it on the exchange to routing.key
-$ex->bind('queue1', 'routing.key');
+$q->bind('exchange1', 'routing.key');
 // Publish a message to the exchange with a routing key
 $ex->publish('message', 'routing.key');
-// Read from the queue
-$msg = $q->consume();
+$response = $q->get();
+if(is_object($response)) {
+    echo $response->getBody();   
+}
+$cnn->disconnect();
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 04:01:38 2024 UTC