amqp.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. declare (strict_types = 1);
  3. use function Hyperf\Support\env;
  4. return [
  5. 'enable' => true,
  6. 'default' => [
  7. 'host' => env('AMQP_HOST', '192.168.1.127'),
  8. 'port' => (int) env('AMQP_PORT', 5672),
  9. 'user' => env('AMQP_USER', 'guest'),
  10. 'password' => env('AMQP_PASSWORD', 'guest'),
  11. 'vhost' => '/',
  12. 'concurrent' => [
  13. 'limit' => 1,
  14. ],
  15. 'pool' => [
  16. 'min_connections' => 1,
  17. 'max_connections' => 1, // 限制最大连接数为1
  18. 'connect_timeout' => 10.0,
  19. 'wait_timeout' => 3.0,
  20. 'heartbeat' => -1,
  21. ],
  22. 'params' => [
  23. 'insist' => false,
  24. 'login_method' => 'AMQPLAIN',
  25. 'login_response' => null,
  26. 'locale' => 'en_US',
  27. 'connection_timeout' => 3.0,
  28. // 尽量保持是 heartbeat 数值的两倍
  29. 'read_write_timeout' => 6.0,
  30. 'context' => null,
  31. 'keepalive' => false,
  32. // 尽量保证每个消息的消费时间小于心跳时间
  33. 'heartbeat' => 3,
  34. 'close_on_destruct' => false,
  35. ],
  36. ],
  37. 'pool2' => [
  38. ],
  39. ];