Skip to content

Instantly share code, notes, and snippets.

@prolic
Created March 7, 2016 21:06
Show Gist options
  • Save prolic/c631b4750e70f1218c46 to your computer and use it in GitHub Desktop.
Save prolic/c631b4750e70f1218c46 to your computer and use it in GitHub Desktop.
Rabbitmq publisher confirm test
<?php
$connection1 = new \AMQPConnection();
$connection1->connect();
$connection2 = new \AMQPConnection();
$connection2->connect();
$channel1 = new \AMQPChannel($connection1);
$channel2 = new \AMQPChannel($connection2);
$exchange = new \AMQPExchange($channel1);
$exchange->setName('test');
$exchange->setType('direct');
$exchange->declareExchange();
$queue = new \AMQPQueue($channel2);
$queue->setName('test');
$queue->declareQueue();
$queue->bind('test');
$channel1->confirmSelect();
$exchange->publish('foo');
$msg = $queue->get();
var_dump($msg->getBody());
$exchange->delete();
$queue->delete();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment