Skip to content

Commit c3ffcea

Browse files
committed
update README
1 parent f292318 commit c3ffcea

File tree

1 file changed

+103
-26
lines changed

1 file changed

+103
-26
lines changed

README.md

Lines changed: 103 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,111 @@ You can install this package via composer using this command:
1414
composer require vladimir-yuldashev/laravel-queue-rabbitmq
1515
```
1616

17-
The package will automatically register itself.
17+
The package will automatically register itself using Laravel auto-discovery.
1818

19-
Add these properties to `.env` with proper values:
19+
Setup connection in `config/queue.php`
2020

21+
```php
22+
'connections' => [
23+
// ...
24+
'rabbitmq' => [
25+
26+
'driver' => 'rabbitmq',
27+
28+
'dsn' => env('RABBITMQ_DSN', null),
29+
30+
/*
31+
* Could be one a class that implements \Interop\Amqp\AmqpConnectionFactory for example:
32+
* - \EnqueueAmqpExt\AmqpConnectionFactory if you install enqueue/amqp-ext
33+
* - \EnqueueAmqpLib\AmqpConnectionFactory if you install enqueue/amqp-lib
34+
* - \EnqueueAmqpBunny\AmqpConnectionFactory if you install enqueue/amqp-bunny
35+
*/
36+
37+
'factory_class' => Enqueue\AmqpLib\AmqpConnectionFactory::class,
38+
39+
'host' => env('RABBITMQ_HOST', '127.0.0.1'),
40+
'port' => env('RABBITMQ_PORT', 5672),
41+
42+
'vhost' => env('RABBITMQ_VHOST', '/'),
43+
'login' => env('RABBITMQ_LOGIN', 'guest'),
44+
'password' => env('RABBITMQ_PASSWORD', 'guest'),
45+
46+
'queue' => env('RABBITMQ_QUEUE', 'default'),
47+
48+
'options' => [
49+
50+
'exchange' => [
51+
52+
'name' => env('RABBITMQ_EXCHANGE_NAME'),
53+
54+
/*
55+
* Determine if exchange should be created if it does not exist.
56+
*/
57+
58+
'declare' => env('RABBITMQ_EXCHANGE_DECLARE', true),
59+
60+
/*
61+
* Read more about possible values at https://www.rabbitmq.com/tutorials/amqp-concepts.html
62+
*/
63+
64+
'type' => env('RABBITMQ_EXCHANGE_TYPE', \Interop\Amqp\AmqpTopic::TYPE_DIRECT),
65+
'passive' => env('RABBITMQ_EXCHANGE_PASSIVE', false),
66+
'durable' => env('RABBITMQ_EXCHANGE_DURABLE', true),
67+
'auto_delete' => env('RABBITMQ_EXCHANGE_AUTODELETE', false),
68+
'arguments' => env('RABBITMQ_EXCHANGE_ARGUMENTS'),
69+
],
70+
71+
'queue' => [
72+
73+
/*
74+
* Determine if queue should be created if it does not exist.
75+
*/
76+
77+
'declare' => env('RABBITMQ_QUEUE_DECLARE', true),
78+
79+
/*
80+
* Determine if queue should be binded to the exchange created.
81+
*/
82+
83+
'bind' => env('RABBITMQ_QUEUE_DECLARE_BIND', true),
84+
85+
/*
86+
* Read more about possible values at https://www.rabbitmq.com/tutorials/amqp-concepts.html
87+
*/
88+
89+
'passive' => env('RABBITMQ_QUEUE_PASSIVE', false),
90+
'durable' => env('RABBITMQ_QUEUE_DURABLE', true),
91+
'exclusive' => env('RABBITMQ_QUEUE_EXCLUSIVE', false),
92+
'auto_delete' => env('RABBITMQ_QUEUE_AUTODELETE', false),
93+
'arguments' => env('RABBITMQ_QUEUE_ARGUMENTS'),
94+
],
95+
],
96+
97+
/*
98+
* Determine the number of seconds to sleep if there's an error communicating with rabbitmq
99+
* If set to false, it'll throw an exception rather than doing the sleep for X seconds.
100+
*/
101+
102+
'sleep_on_error' => env('RABBITMQ_ERROR_SLEEP', 5),
103+
104+
/*
105+
* Optional SSL params if an SSL connection is used
106+
* Using an SSL connection will also require to configure your RabbitMQ to enable SSL. More details can be founds here: https://www.rabbitmq.com/ssl.html
107+
*/
108+
109+
'ssl_params' => [
110+
'ssl_on' => env('RABBITMQ_SSL', false),
111+
'cafile' => env('RABBITMQ_SSL_CAFILE', null),
112+
'local_cert' => env('RABBITMQ_SSL_LOCALCERT', null),
113+
'local_key' => env('RABBITMQ_SSL_LOCALKEY', null),
114+
'verify_peer' => env('RABBITMQ_SSL_VERIFY_PEER', true),
115+
'passphrase' => env('RABBITMQ_SSL_PASSPHRASE', null),
116+
],
117+
118+
],
119+
// ...
120+
],
21121
```
22-
QUEUE_DRIVER=rabbitmq
23-
RABBITMQ_QUEUE=queue_name
24-
25-
RABBITMQ_DSN=amqp: # same as amqp://guest:guest@127.0.0.1:5672/%2F
26-
# or
27-
RABBITMQ_HOST=127.0.0.1
28-
RABBITMQ_PORT=5672
29-
RABBITMQ_VHOST=/
30-
RABBITMQ_LOGIN=guest
31-
RABBITMQ_PASSWORD=guest
32-
RABBITMQ_QUEUE=queue_name
33-
```
34-
35-
Optionally, if you want to to use an SSL connection, add these properties to the `.env` with proper values:
36-
```
37-
RABBITMQ_SSL=true
38-
RABBITMQ_SSL_CAFILE=/path_to_your_ca_file
39-
RABBITMQ_SSL_LOCALCERT=
40-
RABBITMQ_SSL_PASSPHRASE=
41-
RABBITMQ_SSL_KEY=
42-
```
43-
44-
Using an SSL connection will also require to configure your RabbitMQ to enable SSL. More details can be founds here: https://www.rabbitmq.com/ssl.html
45122

46123
## Usage
47124

@@ -62,7 +139,7 @@ composer require enqueue/amqp-bunny:^0.8
62139
Change the factory class in `config/queue.php`:
63140

64141
```php
65-
...
142+
// ...
66143
'connections' => [
67144
'rabbitmq' => [
68145
'driver' => 'rabbitmq',

0 commit comments

Comments
 (0)