Skip to content

Instantly share code, notes, and snippets.

@johndemic
Created March 8, 2012 21:54
Show Gist options
  • Save johndemic/2003703 to your computer and use it in GitHub Desktop.
Save johndemic/2003703 to your computer and use it in GitHub Desktop.
Order Update Consumption with AMQP and PHP
$cnn = new AMQPConnection();
$cnn->connect();
// Create a channel
$ch = new AMQPChannel($cnn);
// Declare the events-exchange
$ex = new AMQPExchange($ch);
$ex->setName("events-exchange");
$ex->setType(AMQP_EX_TYPE_TOPIC);
$ex->setFlags(AMQP_DURABLE);
$ex->declare();
$q = new AMQPQueue($ch);
$q->setName('order-event-consumer');
$q->declare();
$q->bind('events-exchange', 'order.*');
function processOrderEvent($envelope, $queue) {
// do stuff
}
$q->consume("processOrderEvent");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment