note 105946 added to class.amqpqueue
| From: | bolo at nospam dot autistici dot org | Date: | Tue, 27 Sep 2011 10:52:08 +0000 |
| Subject: | note 105946 added to class.amqpqueue | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183471@lists.php.net to get a copy of this message | ||
Functions to send message to Rabbit server.
<?php
//First initialize the connection to the Rabbit server
function amqp_connection() {
$connection = new AMQPConnection();
$connection->setLogin('guest');
$connection->setPassword('guest');
$connection->connect();
if (!$connection->isConnected()) {
echo "Cannot connect to the broker";
}
return $connection;
}
//Next perform message delivery, the FANOUT type is for loadbalacing mode
//It perform the delivery of $text message to every Rabbit servers running in your system.
//Refer to the php manual (http://www.php.net/manual/en/amqp.constants.php) for others type.
function sender($text, $rk, $exchange){
$connection=amqp_connection();
$ex = new AMQPExchange($connection);
$ex->declare($exchange, AMQP_EX_TYPE_FANOUT, AMQP_DURABLE);
$msg=$ex->publish($text, $rk);
if (!$msg){echo "error";}echo 'Sended '.$msg.'<br>';
if (!$connection->disconnect()) {
throw new Exception('Could not disconnect');
} else {
echo "disconnected";
}
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 155.185.212.161
----
Manual Page -- http://www.php.net/manual/en/class.amqpqueue.php
Edit -- https://master.php.net/note/edit/105946
Del: integrated -- https://master.php.net/note/delete/105946/integrated
Del: useless -- https://master.php.net/note/delete/105946/useless
Del: bad code -- https://master.php.net/note/delete/105946/bad+code
Del: spam -- https://master.php.net/note/delete/105946/spam
Del: non-english -- https://master.php.net/note/delete/105946/non-english
Del: in docs -- https://master.php.net/note/delete/105946/in+docs
Del: other reasons-- https://master.php.net/note/delete/105946
Reject -- https://master.php.net/note/reject/105946
Search -- https://master.php.net/manage/user-notes.php