Skip to content

Commit d24a6eb

Browse files
committed
wip
1 parent 46d8ec5 commit d24a6eb

File tree

2 files changed

+58
-44
lines changed

2 files changed

+58
-44
lines changed

config/rabbitmq.php

Lines changed: 54 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,51 +17,63 @@
1717
* - \EnqueueAmqpLib\AmqpConnectionFactory if you install enqueue/amqp-lib
1818
* - \EnqueueAmqpBunny\AmqpConnectionFactory if you install enqueue/amqp-bunny
1919
*/
20-
'factory_class' => \Enqueue\AmqpLib\AmqpConnectionFactory::class,
20+
'factory_class' => Enqueue\AmqpLib\AmqpConnectionFactory::class,
2121

2222
'host' => env('RABBITMQ_HOST', '127.0.0.1'),
2323
'port' => env('RABBITMQ_PORT', 5672),
2424

25-
'vhost' => env('RABBITMQ_VHOST', '/'),
26-
'login' => env('RABBITMQ_LOGIN', 'guest'),
25+
'vhost' => env('RABBITMQ_VHOST', '/'),
26+
'login' => env('RABBITMQ_LOGIN', 'guest'),
2727
'password' => env('RABBITMQ_PASSWORD', 'guest'),
2828

29-
/*
30-
* The name of default queue.
31-
*/
32-
'queue' => env('RABBITMQ_QUEUE'),
29+
'options' => [
3330

34-
/*
35-
* Determine if exchange should be created if it does not exist.
36-
*/
37-
'exchange_declare' => env('RABBITMQ_EXCHANGE_DECLARE', true),
31+
'exchange' => [
3832

39-
/*
40-
* Determine if queue should be created if it does not exist.
41-
*/
42-
'queue_declare' => env('RABBITMQ_QUEUE_DECLARE', true),
33+
'name' => env('RABBITMQ_EXCHANGE_NAME'),
4334

44-
/*
45-
* Determine if queue should be created and binded to the exchange if it does not exist.
46-
*/
47-
'queue_declare_bind' => env('RABBITMQ_QUEUE_DECLARE_BIND', true),
35+
/*
36+
* Determine if exchange should be created if it does not exist.
37+
*/
38+
'declare' => env('RABBITMQ_EXCHANGE_DECLARE', true),
39+
40+
/*
41+
* Read more about possible values at https://www.rabbitmq.com/tutorials/amqp-concepts.html
42+
*/
43+
'type' => env('RABBITMQ_EXCHANGE_TYPE', \Interop\Amqp\AmqpTopic::TYPE_DIRECT),
44+
'passive' => env('RABBITMQ_EXCHANGE_PASSIVE', false),
45+
'durable' => env('RABBITMQ_EXCHANGE_DURABLE', true),
46+
'auto_delete' => env('RABBITMQ_EXCHANGE_AUTODELETE', false),
47+
],
48+
49+
'queue' => [
50+
51+
/*
52+
* The name of default queue.
53+
*/
54+
'name' => env('RABBITMQ_QUEUE', 'default'),
55+
56+
/*
57+
* Determine if queue should be created if it does not exist.
58+
*/
59+
'declare' => env('RABBITMQ_QUEUE_DECLARE', true),
60+
61+
/*
62+
* Determine if queue should be binded to the exchange created.
63+
*/
64+
'bind' => env('RABBITMQ_QUEUE_DECLARE_BIND', true),
65+
66+
/*
67+
* Read more about possible values at https://www.rabbitmq.com/tutorials/amqp-concepts.html
68+
*/
69+
'passive' => env('RABBITMQ_QUEUE_PASSIVE', false),
70+
'durable' => env('RABBITMQ_QUEUE_DURABLE', true),
71+
'exclusive' => env('RABBITMQ_QUEUE_EXCLUSIVE', false),
72+
'auto_delete' => env('RABBITMQ_QUEUE_AUTODELETE', false),
73+
'arguments' => env('RABBITMQ_QUEUE_ARGUMENTS'),
74+
75+
],
4876

49-
/*
50-
* Read more about possible values at https://www.rabbitmq.com/tutorials/amqp-concepts.html
51-
*/
52-
'queue_params' => [
53-
'passive' => env('RABBITMQ_QUEUE_PASSIVE', false),
54-
'durable' => env('RABBITMQ_QUEUE_DURABLE', true),
55-
'exclusive' => env('RABBITMQ_QUEUE_EXCLUSIVE', false),
56-
'auto_delete' => env('RABBITMQ_QUEUE_AUTODELETE', false),
57-
'arguments' => env('RABBITMQ_QUEUE_ARGUMENTS'),
58-
],
59-
'exchange_params' => [
60-
'name' => env('RABBITMQ_EXCHANGE_NAME'),
61-
'type' => env('RABBITMQ_EXCHANGE_TYPE', \Interop\Amqp\AmqpTopic::TYPE_DIRECT),
62-
'passive' => env('RABBITMQ_EXCHANGE_PASSIVE', false),
63-
'durable' => env('RABBITMQ_EXCHANGE_DURABLE', true),
64-
'auto_delete' => env('RABBITMQ_EXCHANGE_AUTODELETE', false),
6577
],
6678

6779
/*
@@ -74,12 +86,12 @@
7486
* Optional SSL params if an SSL connection is used
7587
*/
7688
'ssl_params' => [
77-
'ssl_on' => env('RABBITMQ_SSL', false),
78-
'cafile' => env('RABBITMQ_SSL_CAFILE', null),
79-
'local_cert' => env('RABBITMQ_SSL_LOCALCERT', null),
80-
'local_key' => env('RABBITMQ_SSL_LOCALKEY', null),
81-
'verify_peer' => env('RABBITMQ_SSL_VERIFY_PEER', true),
82-
'passphrase' => env('RABBITMQ_SSL_PASSPHRASE', null),
83-
]
89+
'ssl_on' => env('RABBITMQ_SSL', false),
90+
'cafile' => env('RABBITMQ_SSL_CAFILE', null),
91+
'local_cert' => env('RABBITMQ_SSL_LOCALCERT', null),
92+
'local_key' => env('RABBITMQ_SSL_LOCALKEY', null),
93+
'verify_peer' => env('RABBITMQ_SSL_VERIFY_PEER', true),
94+
'passphrase' => env('RABBITMQ_SSL_PASSPHRASE', null),
95+
],
8496

8597
];

src/Queue/Connectors/RabbitMQConnector.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Illuminate\Queue\Events\WorkerStopping;
1111
use Interop\Amqp\AmqpConnectionFactory as InteropAmqpConnectionFactory;
1212
use Interop\Amqp\AmqpConnectionFactory;
13+
use Interop\Amqp\AmqpContext;
1314
use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue;
1415

1516
class RabbitMQConnector implements ConnectorInterface
@@ -33,12 +34,12 @@ public function __construct(Dispatcher $dispatcher)
3334
*/
3435
public function connect(array $config): Queue
3536
{
36-
if (false == array_key_exists('factory_class', $config)) {
37+
if (false === array_key_exists('factory_class', $config)) {
3738
throw new \LogicException('The factory_class option is missing though it is required.');
3839
}
3940

4041
$factoryClass = $config['factory_class'];
41-
if (false == class_exists($factoryClass) || false == (new \ReflectionClass($factoryClass))->implementsInterface(InteropAmqpConnectionFactory::class)) {
42+
if (false === class_exists($factoryClass) || false === (new \ReflectionClass($factoryClass))->implementsInterface(InteropAmqpConnectionFactory::class)) {
4243
throw new \LogicException(sprintf('The factory_class option has to be valid class that implements "%s"', InteropAmqpConnectionFactory::class));
4344
}
4445

@@ -62,6 +63,7 @@ public function connect(array $config): Queue
6263
$factory->setDelayStrategy(new RabbitMqDlxDelayStrategy());
6364
}
6465

66+
/** @var AmqpContext $context */
6567
$context = $factory->createContext();
6668

6769
$this->dispatcher->listen(WorkerStopping::class, function () use ($context) {

0 commit comments

Comments
 (0)