box-o-sand/sylvilagus/php/rabbitmqctl-examples.php

33 lines
814 B
PHP
Raw Normal View History

<?php
define('AMQP_DEBUG', true);
require_once(__DIR__ . '/php-amqplib/vendor/autoload.php');
use PhpAmqpLib\Connection\AMQPConnection;
use PhpAmqpLib\Message\AMQPMessage;
$uri = parse_url(getenv('SYLVILAGUS_AMQP_URI'));
$conn = new AMQPConnection(
$uri['host'],
$uri['port'],
$uri['user'],
$uri['pass'],
$uri['path']
);
$channel = $conn->channel();
$channel->exchange_declare('logs-exchange', 'topic', false, true, false);
$channel->queue_declare('msg-inbox-errors', false, true, false, false);
$channel->queue_declare('msg-inbox-logs', false, true, false, false);
$channel->queue_declare('all-logs', false, true, false, false);
$channel->queue_bind('msg-inbox-errors', 'logs-exchange', 'error.msg-inbox');
$channel->queue_bind('msg-inbox-logs', 'logs-exchange', '*.msg-inbox');
?>