Created
March 7, 2012 22:49
-
-
Save johndemic/1996848 to your computer and use it in GitHub Desktop.
A script to publish messages to an AMQP exchange
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Establish a connection to the locally running RabbitMQ instance | |
$cnn = new AMQPConnection(); | |
$cnn->connect(); | |
// Create a channel | |
$ch = new AMQPChannel($cnn); | |
// Declare the exchange specified by the first argument to the script | |
$ex = new AMQPExchange($ch); | |
$ex->setName($argv[1]); | |
$ex->setType(AMQP_EX_TYPE_TOPIC); | |
$ex->setFlags(AMQP_DURABLE); | |
$ex->declare(); | |
// Publish a message to the exchange with the given routing key | |
$msg = $ex->publish($argv[3], $argv[2], AMQP_NOPARAM, | |
array("Content-type" => "text/plain")); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment