rabbitMQ.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. /**
  3. * rabbitmq的配置
  4. */
  5. $rabbitMQ = [
  6. 'class' => 'mikemadisonweb\rabbitmq\Configuration',
  7. 'connections' => [
  8. [
  9. 'host' => '127.0.0.1',
  10. 'port' => '5672',
  11. 'user' => 'admin',
  12. 'password' => 'Kn3oaz138w52kzmm9',
  13. 'vhost' => '/', //虚拟主机
  14. ]
  15. ],
  16. /**
  17. * 交换器
  18. */
  19. 'exchanges' => [
  20. [
  21. 'name' => 'customExchange',
  22. 'type' => 'direct',
  23. ],
  24. [
  25. 'name' => 'stockExchange',
  26. 'type' => 'direct',
  27. ],
  28. [
  29. 'name' => 'notifyExchange',
  30. 'type' => 'direct',
  31. ],
  32. [
  33. 'name' => 'ex1',
  34. 'type' => 'direct'
  35. ]
  36. ],
  37. /**
  38. * 队列
  39. */
  40. 'queues' => [
  41. [
  42. 'name' => 'queues1',
  43. 'passive' => false,
  44. ],
  45. [
  46. 'name' => 'customQueue',
  47. 'passive' => false,
  48. ],
  49. [
  50. 'name' => 'stockQueue',
  51. 'passive' => false,
  52. ],
  53. [
  54. 'name' => 'notifyQueue',
  55. 'passive' => false,
  56. ],
  57. ],
  58. /**
  59. * 交换和队列之间的关系称为绑定
  60. * 列出绑定: rabbitmqctl list_bindings
  61. */
  62. 'bindings' => [
  63. [
  64. 'queue' => 'customQueue',
  65. 'exchange' => 'customExchange',
  66. 'routing_keys' => ['customRoute'],
  67. ],
  68. [
  69. 'queue' => 'stockQueue',
  70. 'exchange' => 'stockExchange',
  71. 'routing_keys' => ['stockRoute'],
  72. ],
  73. [
  74. 'queue' => 'notifyQueue',
  75. 'exchange' => 'notifyExchange',
  76. 'routing_keys' => ['notifyRoute'],
  77. ],
  78. [
  79. 'queue' => 'queues1',
  80. 'exchange' => 'ex1',
  81. 'routing_keys' => ['route1'],
  82. ],
  83. ],
  84. /**
  85. * 生产者
  86. */
  87. 'producers' => [
  88. [
  89. //客户操作生产者
  90. 'name' => 'customProducer',
  91. ],
  92. [
  93. //库存管理生产者
  94. 'name' => 'stockProducer',
  95. ],
  96. [
  97. //通知生产者
  98. 'name' => 'notifyProducer',
  99. ],
  100. [
  101. 'name' => 'importDataProducer',
  102. ]
  103. ],
  104. /**
  105. * 消费者
  106. */
  107. 'consumers' => [
  108. [
  109. //客户操作消费者
  110. 'name' => 'customConsumer',
  111. 'callbacks' => [
  112. 'customQueue' => '\common\components\rabbitmq\customConsumer',
  113. ]
  114. ],
  115. [
  116. //库存管理消费者
  117. 'name' => 'stockConsumer',
  118. 'callbacks' => [
  119. 'stockQueue' => '\common\components\rabbitmq\stockConsumer',
  120. ]
  121. ],
  122. [
  123. //通知消费者
  124. 'name' => 'notifyConsumer',
  125. 'callbacks' => [
  126. 'notifyQueue' => '\common\components\rabbitmq\notifyConsumer',
  127. ]
  128. ],
  129. [
  130. 'name' => 'importDataConsumer',
  131. 'callbacks' => [
  132. 'queues1' => '\common\components\rabbitmq\importDataConsumer',
  133. ],
  134. ]
  135. ],
  136. ];
  137. return $rabbitMQ;