1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| 'localhost' , 'port'=> '5672', 'login'=>'guest' , 'password'=> 'guest','vhost' =>'/'); $conn = new AMQPConnection($conn_args); $conn->connect();
$channel = new AMQPChannel($conn); $ex = new AMQPExchange($channel); $ex->setName('direct_exchange_name'); $ex->setType(AMQP_EX_TYPE_DIRECT); $ex->setFlags(AMQP_DURABLE | AMQP_AUTODELETE); $ex->declare();
$q = new AMQPQueue($channel); $q->setName('queue_name'); $q->setFlags(AMQP_DURABLE | AMQP_AUTODELETE); $q->declare(); $q->bind('direct_exchange_name', 'routingkey_name');
$channel->startTransaction(); $message = json_encode(array('Hello World!','DIRECT')); $ex->publish($message, 'routingkey_name'); $channel->commitTransaction(); $conn->disconnect(); ?>
|