| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <?php
- /**
- * rabbitmq的配置
- */
- $rabbitMQ = [
- 'class' => 'mikemadisonweb\rabbitmq\Configuration',
- 'connections' => [
- [
- 'host' => '127.0.0.1',
- 'port' => '5672',
- 'user' => 'admin',
- 'password' => 'Kn3oaz138w52kzmm9',
- 'vhost' => '/', //虚拟主机
- ]
- ],
- /**
- * 交换器
- */
- 'exchanges' => [
- [
- 'name' => 'customExchange',
- 'type' => 'direct',
- ],
- [
- 'name' => 'stockExchange',
- 'type' => 'direct',
- ],
- [
- 'name' => 'notifyExchange',
- 'type' => 'direct',
- ],
- [
- 'name' => 'ex1',
- 'type' => 'direct'
- ]
- ],
- /**
- * 队列
- */
- 'queues' => [
- [
- 'name' => 'queues1',
- 'passive' => false,
- ],
- [
- 'name' => 'customQueue',
- 'passive' => false,
- ],
- [
- 'name' => 'stockQueue',
- 'passive' => false,
- ],
- [
- 'name' => 'notifyQueue',
- 'passive' => false,
- ],
- ],
- /**
- * 交换和队列之间的关系称为绑定
- * 列出绑定: rabbitmqctl list_bindings
- */
- 'bindings' => [
- [
- 'queue' => 'customQueue',
- 'exchange' => 'customExchange',
- 'routing_keys' => ['customRoute'],
- ],
- [
- 'queue' => 'stockQueue',
- 'exchange' => 'stockExchange',
- 'routing_keys' => ['stockRoute'],
- ],
- [
- 'queue' => 'notifyQueue',
- 'exchange' => 'notifyExchange',
- 'routing_keys' => ['notifyRoute'],
- ],
- [
- 'queue' => 'queues1',
- 'exchange' => 'ex1',
- 'routing_keys' => ['route1'],
- ],
- ],
- /**
- * 生产者
- */
- 'producers' => [
- [
- //客户操作生产者
- 'name' => 'customProducer',
- ],
- [
- //库存管理生产者
- 'name' => 'stockProducer',
- ],
- [
- //通知生产者
- 'name' => 'notifyProducer',
- ],
- [
- 'name' => 'importDataProducer',
- ]
- ],
- /**
- * 消费者
- */
- 'consumers' => [
- [
- //客户操作消费者
- 'name' => 'customConsumer',
- 'callbacks' => [
- 'customQueue' => '\common\components\rabbitmq\customConsumer',
- ]
- ],
- [
- //库存管理消费者
- 'name' => 'stockConsumer',
- 'callbacks' => [
- 'stockQueue' => '\common\components\rabbitmq\stockConsumer',
- ]
- ],
- [
- //通知消费者
- 'name' => 'notifyConsumer',
- 'callbacks' => [
- 'notifyQueue' => '\common\components\rabbitmq\notifyConsumer',
- ]
- ],
- [
- 'name' => 'importDataConsumer',
- 'callbacks' => [
- 'queues1' => '\common\components\rabbitmq\importDataConsumer',
- ],
- ]
- ],
- ];
- return $rabbitMQ;
|