Skip to content

Commit 803a416

Browse files
authored
1 parent b78c79a commit 803a416

30 files changed

+1085
-1469
lines changed

.gitattributes

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
* text=auto
2+
3+
/.github export-ignore
4+
/tests export-ignore
5+
.editorconfig export-ignore
6+
.gitattributes export-ignore
7+
.gitignore export-ignore
8+
.styleci.yml export-ignore
9+
.travis.yml export-ignore
10+
.php_cs.dist export-ignore
11+
CHANGELOG-* export-ignore
12+
CODE_OF_CONDUCT.md export-ignore
13+
CONTRIBUTING.md export-ignore
14+
phpunit.xml.dist export-ignore
15+
docker-compose.yml export-ignore

.php_cs.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,8 @@ return PhpCsFixer\Config::create()
5050
],
5151
'fully_qualified_strict_types' => true,
5252
'void_return' => true,
53+
'cast_spaces' => [
54+
'space' => 'single',
55+
],
56+
'not_operator_with_successor_space' => true,
5357
]);

.styleci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
preset: laravel
2+
3+
disabled:
4+
- simplified_null_return

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ language: php
33
php:
44
- 7.2
55
- 7.3
6-
- 7.4snapshot
76

87
services:
98
- docker
@@ -19,7 +18,7 @@ before_install:
1918
- sudo mv docker-compose /usr/local/bin
2019

2120
before_script:
22-
- docker-compose up -d
21+
- docker-compose up -d rabbitmq
2322
- travis_retry composer self-update
2423
- travis_retry composer update --no-progress --no-interaction --prefer-dist
2524
- sleep 10

README.md

Lines changed: 42 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ RabbitMQ Queue driver for Laravel
66
[![StyleCI](https://styleci.io/repos/14976752/shield)](https://styleci.io/repos/14976752)
77
[![License](https://poser.pugx.org/vladimir-yuldashev/laravel-queue-rabbitmq/license?format=flat-square)](https://packagist.org/packages/vladimir-yuldashev/laravel-queue-rabbitmq)
88

9+
## Support Policy
10+
11+
| Package Version | Laravel Version | Bug Fixes Until |
12+
|-----------------|-----------------|---------------------|
13+
| 6.0 | 5.5 | August 30th, 2019 |
14+
| 7.0 | 5.6 | August 7th, 2018 |
15+
| 7.1 | 5.7 | March 4th, 2019 |
16+
| 7.2 | 5.8 | August 26th, 2019 |
17+
| 9 | 6 | September 3rd, 2021 |
18+
| 10 | 6 | September 3rd, 2021 |
19+
920
## Installation
1021

1122
You can install this package via composer using this command:
@@ -21,106 +32,40 @@ Setup connection in `config/queue.php`
2132
```php
2233
'connections' => [
2334
// ...
35+
2436
'rabbitmq' => [
2537

26-
'driver' => 'rabbitmq',
27-
28-
/*
29-
* Set to "horizon" if you wish to use Laravel Horizon.
30-
*/
31-
'worker' => env('RABBITMQ_WORKER', 'default'),
32-
33-
'dsn' => env('RABBITMQ_DSN', null),
34-
35-
/*
36-
* Could be one a class that implements \Interop\Amqp\AmqpConnectionFactory for example:
37-
* - \EnqueueAmqpExt\AmqpConnectionFactory if you install enqueue/amqp-ext
38-
* - \EnqueueAmqpLib\AmqpConnectionFactory if you install enqueue/amqp-lib
39-
* - \EnqueueAmqpBunny\AmqpConnectionFactory if you install enqueue/amqp-bunny
40-
*/
41-
42-
'factory_class' => Enqueue\AmqpLib\AmqpConnectionFactory::class,
43-
44-
'host' => env('RABBITMQ_HOST', '127.0.0.1'),
45-
'port' => env('RABBITMQ_PORT', 5672),
46-
47-
'vhost' => env('RABBITMQ_VHOST', '/'),
48-
'login' => env('RABBITMQ_LOGIN', 'guest'),
49-
'password' => env('RABBITMQ_PASSWORD', 'guest'),
50-
51-
'queue' => env('RABBITMQ_QUEUE', 'default'),
52-
53-
'options' => [
54-
55-
'exchange' => [
56-
57-
'name' => env('RABBITMQ_EXCHANGE_NAME'),
58-
59-
/*
60-
* Determine if exchange should be created if it does not exist.
61-
*/
62-
63-
'declare' => env('RABBITMQ_EXCHANGE_DECLARE', true),
64-
65-
/*
66-
* Read more about possible values at https://www.rabbitmq.com/tutorials/amqp-concepts.html
67-
*/
68-
69-
'type' => env('RABBITMQ_EXCHANGE_TYPE', \Interop\Amqp\AmqpTopic::TYPE_DIRECT),
70-
'passive' => env('RABBITMQ_EXCHANGE_PASSIVE', false),
71-
'durable' => env('RABBITMQ_EXCHANGE_DURABLE', true),
72-
'auto_delete' => env('RABBITMQ_EXCHANGE_AUTODELETE', false),
73-
'arguments' => env('RABBITMQ_EXCHANGE_ARGUMENTS'),
74-
],
75-
76-
'queue' => [
77-
78-
/*
79-
* Determine if queue should be created if it does not exist.
80-
*/
81-
82-
'declare' => env('RABBITMQ_QUEUE_DECLARE', true),
83-
84-
/*
85-
* Determine if queue should be binded to the exchange created.
86-
*/
87-
88-
'bind' => env('RABBITMQ_QUEUE_DECLARE_BIND', true),
89-
90-
/*
91-
* Read more about possible values at https://www.rabbitmq.com/tutorials/amqp-concepts.html
92-
*/
93-
94-
'passive' => env('RABBITMQ_QUEUE_PASSIVE', false),
95-
'durable' => env('RABBITMQ_QUEUE_DURABLE', true),
96-
'exclusive' => env('RABBITMQ_QUEUE_EXCLUSIVE', false),
97-
'auto_delete' => env('RABBITMQ_QUEUE_AUTODELETE', false),
98-
'arguments' => env('RABBITMQ_QUEUE_ARGUMENTS'),
99-
],
100-
],
101-
102-
/*
103-
* Determine the number of seconds to sleep if there's an error communicating with rabbitmq
104-
* If set to false, it'll throw an exception rather than doing the sleep for X seconds.
105-
*/
106-
107-
'sleep_on_error' => env('RABBITMQ_ERROR_SLEEP', 5),
108-
109-
/*
110-
* Optional SSL params if an SSL connection is used
111-
* 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
112-
*/
113-
114-
'ssl_params' => [
115-
'ssl_on' => env('RABBITMQ_SSL', false),
116-
'cafile' => env('RABBITMQ_SSL_CAFILE', null),
117-
'local_cert' => env('RABBITMQ_SSL_LOCALCERT', null),
118-
'local_key' => env('RABBITMQ_SSL_LOCALKEY', null),
119-
'verify_peer' => env('RABBITMQ_SSL_VERIFY_PEER', true),
120-
'passphrase' => env('RABBITMQ_SSL_PASSPHRASE', null),
121-
],
38+
'driver' => 'rabbitmq',
39+
'queue' => env('RABBITMQ_QUEUE', 'default'),
40+
'connection' => PhpAmqpLib\Connection\AMQPLazyConnection::class,
41+
42+
'hosts' => [
43+
[
44+
'host' => env('RABBITMQ_HOST', '127.0.0.1'),
45+
'port' => env('RABBITMQ_PORT', 5672),
46+
'user' => env('RABBITMQ_USER', 'guest'),
47+
'password' => env('RABBITMQ_PASSWORD', 'guest'),
48+
'vhost' => env('RABBITMQ_VHOST', '/'),
49+
],
50+
],
51+
52+
'options' => [
53+
'ssl_options' => [
54+
'cafile' => env('RABBITMQ_SSL_CAFILE', null),
55+
'local_cert' => env('RABBITMQ_SSL_LOCALCERT', null),
56+
'local_key' => env('RABBITMQ_SSL_LOCALKEY', null),
57+
'verify_peer' => env('RABBITMQ_SSL_VERIFY_PEER', true),
58+
'passphrase' => env('RABBITMQ_SSL_PASSPHRASE', null),
59+
],
60+
],
61+
62+
/*
63+
* Set to "horizon" if you wish to use Laravel Horizon.
64+
*/
65+
'worker' => env('RABBITMQ_WORKER', 'default'),
12266

12367
],
68+
12469
// ...
12570
],
12671
```
@@ -141,37 +86,12 @@ For Lumen usage the service provider should be registered manually as follow in
14186
$app->register(VladimirYuldashev\LaravelQueueRabbitMQ\LaravelQueueRabbitMQServiceProvider::class);
14287
```
14388

144-
145-
## Using other AMQP transports
146-
147-
The package uses [enqueue/amqp-lib](https://github.com/php-enqueue/enqueue-dev/blob/master/docs/transport/amqp_lib.md) transport which is based on [php-amqplib](https://github.com/php-amqplib/php-amqplib).
148-
There is possibility to use any [amqp interop](https://github.com/queue-interop/queue-interop#amqp-interop) compatible transport, for example `enqueue/amqp-ext` or `enqueue/amqp-bunny`.
149-
Here's an example on how one can change the transport to `enqueue/amqp-bunny`.
150-
151-
First, install desired transport package:
152-
153-
```bash
154-
composer require enqueue/amqp-bunny:^0.8
155-
```
156-
157-
Change the factory class in `config/queue.php`:
158-
159-
```php
160-
// ...
161-
'connections' => [
162-
'rabbitmq' => [
163-
'driver' => 'rabbitmq',
164-
'factory_class' => Enqueue\AmqpBunny\AmqpConnectionFactory::class,
165-
],
166-
],
167-
```
168-
16989
## Testing
17090

17191
Setup RabbitMQ using `docker-compose`:
17292

17393
```bash
174-
docker-compose up -d
94+
docker-compose up -d rabbitmq
17595
```
17696

17797
To run the test suite you can use the following commands:

composer.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vladimir-yuldashev/laravel-queue-rabbitmq",
3-
"description": "RabbitMQ driver for Laravel Queue. Supports Laravel Horizon",
3+
"description": "RabbitMQ driver for Laravel Queue. Supports Laravel Horizon.",
44
"license": "MIT",
55
"authors": [
66
{
@@ -14,15 +14,13 @@
1414
"illuminate/database": "^6.0",
1515
"illuminate/support": "^6.0",
1616
"illuminate/queue": "^6.0",
17-
"enqueue/amqp-lib": "0.9.*",
18-
"queue-interop/amqp-interop": "0.8.*"
17+
"php-amqplib/php-amqplib": "^2.11"
1918
},
2019
"require-dev": {
2120
"phpunit/phpunit": "^8.4",
2221
"illuminate/events": "^6.0",
2322
"mockery/mockery": "^1.0",
2423
"laravel/horizon": "^3.0",
25-
"larapack/dd": "^1.1",
2624
"friendsofphp/php-cs-fixer": "^2.16",
2725
"orchestra/testbench": "^4.3"
2826
},

config/rabbitmq.php

Lines changed: 19 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -8,85 +8,32 @@
88
return [
99

1010
'driver' => 'rabbitmq',
11-
12-
/*
13-
* Set to "horizon" if you wish to use Laravel Horizon.
14-
*/
15-
'worker' => env('RABBITMQ_WORKER', 'default'),
16-
17-
'dsn' => env('RABBITMQ_DSN', null),
18-
19-
/*
20-
* Could be one a class that implements \Interop\Amqp\AmqpConnectionFactory for example:
21-
* - \EnqueueAmqpExt\AmqpConnectionFactory if you install enqueue/amqp-ext
22-
* - \EnqueueAmqpLib\AmqpConnectionFactory if you install enqueue/amqp-lib
23-
* - \EnqueueAmqpBunny\AmqpConnectionFactory if you install enqueue/amqp-bunny
24-
*/
25-
'factory_class' => Enqueue\AmqpLib\AmqpConnectionFactory::class,
26-
27-
'host' => env('RABBITMQ_HOST', '127.0.0.1'),
28-
'port' => env('RABBITMQ_PORT', 5672),
29-
30-
'vhost' => env('RABBITMQ_VHOST', '/'),
31-
'login' => env('RABBITMQ_LOGIN', 'guest'),
32-
'password' => env('RABBITMQ_PASSWORD', 'guest'),
33-
3411
'queue' => env('RABBITMQ_QUEUE', 'default'),
35-
36-
'options' => [
37-
38-
'exchange' => [
39-
40-
'name' => env('RABBITMQ_EXCHANGE_NAME'),
41-
42-
/*
43-
* Determine if exchange should be created if it does not exist.
44-
*/
45-
'declare' => env('RABBITMQ_EXCHANGE_DECLARE', true),
46-
47-
/*
48-
* Read more about possible values at https://www.rabbitmq.com/tutorials/amqp-concepts.html
49-
*/
50-
'type' => env('RABBITMQ_EXCHANGE_TYPE', \Interop\Amqp\AmqpTopic::TYPE_DIRECT),
51-
'passive' => env('RABBITMQ_EXCHANGE_PASSIVE', false),
52-
'durable' => env('RABBITMQ_EXCHANGE_DURABLE', true),
53-
'auto_delete' => env('RABBITMQ_EXCHANGE_AUTODELETE', false),
54-
'arguments' => env('RABBITMQ_EXCHANGE_ARGUMENTS'),
12+
'connection' => PhpAmqpLib\Connection\AMQPLazyConnection::class,
13+
14+
'hosts' => [
15+
[
16+
'host' => env('RABBITMQ_HOST', '127.0.0.1'),
17+
'port' => env('RABBITMQ_PORT', 5672),
18+
'user' => env('RABBITMQ_USER', 'guest'),
19+
'password' => env('RABBITMQ_PASSWORD', 'guest'),
20+
'vhost' => env('RABBITMQ_VHOST', '/'),
5521
],
22+
],
5623

57-
'queue' => [
58-
59-
/*
60-
* Determine if queue should be created if it does not exist.
61-
*/
62-
'declare' => env('RABBITMQ_QUEUE_DECLARE', true),
63-
64-
/*
65-
* Determine if queue should be binded to the exchange created.
66-
*/
67-
'bind' => env('RABBITMQ_QUEUE_DECLARE_BIND', true),
68-
69-
/*
70-
* Read more about possible values at https://www.rabbitmq.com/tutorials/amqp-concepts.html
71-
*/
72-
'passive' => env('RABBITMQ_QUEUE_PASSIVE', false),
73-
'durable' => env('RABBITMQ_QUEUE_DURABLE', true),
74-
'exclusive' => env('RABBITMQ_QUEUE_EXCLUSIVE', false),
75-
'auto_delete' => env('RABBITMQ_QUEUE_AUTODELETE', false),
76-
'arguments' => env('RABBITMQ_QUEUE_ARGUMENTS'),
24+
'options' => [
25+
'ssl_options' => [
26+
'cafile' => env('RABBITMQ_SSL_CAFILE', null),
27+
'local_cert' => env('RABBITMQ_SSL_LOCALCERT', null),
28+
'local_key' => env('RABBITMQ_SSL_LOCALKEY', null),
29+
'verify_peer' => env('RABBITMQ_SSL_VERIFY_PEER', true),
30+
'passphrase' => env('RABBITMQ_SSL_PASSPHRASE', null),
7731
],
7832
],
7933

8034
/*
81-
* Optional SSL params if an SSL connection is used
35+
* Set to "horizon" if you wish to use Laravel Horizon.
8236
*/
83-
'ssl_params' => [
84-
'ssl_on' => env('RABBITMQ_SSL', false),
85-
'cafile' => env('RABBITMQ_SSL_CAFILE', null),
86-
'local_cert' => env('RABBITMQ_SSL_LOCALCERT', null),
87-
'local_key' => env('RABBITMQ_SSL_LOCALKEY', null),
88-
'verify_peer' => env('RABBITMQ_SSL_VERIFY_PEER', true),
89-
'passphrase' => env('RABBITMQ_SSL_PASSPHRASE', null),
90-
],
37+
'worker' => env('RABBITMQ_WORKER', 'default'),
9138

9239
];

docker-compose.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,27 @@ services:
1717
- "./tests/files/rootCA.pem:/rootCA.pem:ro"
1818
- "./tests/files/rootCA.key:/rootCA.key:ro"
1919
ports:
20+
- 15671:15671
21+
- 15672:15672
22+
- 5671:5671
23+
- 5672:5672
24+
25+
rabbitmq-management:
26+
image: rabbitmq:management
27+
environment:
28+
RABBITMQ_DEFAULT_USER: guest
29+
RABBITMQ_DEFAULT_PASSWORD: guest
30+
RABBITMQ_DEFAULT_VHOST: /
31+
RABBITMQ_MANAGEMENT_SSL_CACERTFILE: /rootCA.pem
32+
RABBITMQ_MANAGEMENT_SSL_CERTFILE: /rootCA.pem
33+
RABBITMQ_MANAGEMENT_SSL_KEYFILE: /rootCA.key
34+
RABBITMQ_MANAGEMENT_SSL_VERIFY: verify_none
35+
RABBITMQ_MANAGEMENT_SSL_FAIL_IF_NO_PEER_CERT: "false"
36+
volumes:
37+
- "./tests/files/rootCA.pem:/rootCA.pem:ro"
38+
- "./tests/files/rootCA.key:/rootCA.key:ro"
39+
ports:
40+
- 15671:15671
41+
- 15672:15672
2042
- 5671:5671
2143
- 5672:5672

0 commit comments

Comments
 (0)