diff --git a/php/chapter-3/log-listeners-debian.php b/php/chapter-3/log-listeners-debian.php new file mode 100644 index 0000000..045de19 --- /dev/null +++ b/php/chapter-3/log-listeners-debian.php @@ -0,0 +1,51 @@ +channel(); + +list($errors_queue, , ) = $ch->queue_declare(); +list($warnings_queue, , ) = $ch->queue_declare(); +list($info_queue, , ) = $ch->queue_declare(); + +$exchange = 'amq.rabbitmq.log'; + +$ch->queue_bind($errors_queue, $exchange, "error"); +$ch->queue_bind($warnings_queue, $exchange, "warning"); +$ch->queue_bind($info_queue, $exchange, "info"); + +$error_callback = function($msg) { + echo 'error: ', $msg->body, "\n"; + $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']); +}; + +$warning_callback = function($msg) { + echo 'warning: ', $msg->body, "\n"; + $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']); +}; + +$info_callback = function($msg) { + echo 'info: ', $msg->body, "\n"; + $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']); +}; + +$ch->basic_consume($errors_queue, "", false, + false, false, false, + $error_callback); + +$ch->basic_consume($warnings_queue, "", false, + false, false, false, + $warning_callback); + +$ch->basic_consume($info_queue, "", false, + false, false, false, + $info_callback); + +while(count($ch->callbacks)) { + $ch->wait(); +} + +?> diff --git a/php/chapter-3/rabbitmqctl-examples-debian.php b/php/chapter-3/rabbitmqctl-examples-debian.php new file mode 100644 index 0000000..fe0fad7 --- /dev/null +++ b/php/chapter-3/rabbitmqctl-examples-debian.php @@ -0,0 +1,31 @@ +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'); + +?> diff --git a/php/config/config-debian.php b/php/config/config-debian.php new file mode 100644 index 0000000..4020ce0 --- /dev/null +++ b/php/config/config-debian.php @@ -0,0 +1,23 @@ + \ No newline at end of file