Skip to content

Commit 09b213e

Browse files
authored
Merge pull request #1 from bckp/feature-dlx-queues
Added DLX feature for queues
2 parents 637ead4 + fa4ef4c commit 09b213e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+404
-274
lines changed

.docs/README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ config.neon:
1818

1919
```neon
2020
extensions:
21-
rabbitmq: Mallgroup\RabbitMQ\DI\RabbitMQExtension
21+
rabbitmq: Bckp\RabbitMQ\DI\RabbitMQExtension
2222
```
2323

2424
### Example configuration
@@ -47,6 +47,13 @@ rabbitmq:
4747
# false - do not declare (will fail if not created)
4848
# never - do not declare even if command is called, this one is mainly for no-permissions state
4949
50+
autoDlxQueue:
51+
connection: default
52+
autoCreate: true
53+
dlx: [+5min, +15min]
54+
# Will create automaticly 2 new dlx queues and exchanges to handle them
55+
# if message is rejected in queue, it will go to first DLX, on second reject it will go to second DLX, on third will be throwed away
56+
5057
exchanges:
5158
testExchange:
5259
connection: default
@@ -111,7 +118,7 @@ rabbitmq:
111118
# Enable tracy bar panel
112119
tracy:
113120
bar:
114-
- Mallgroup\RabbitMQ\Diagnostics\BarPanel
121+
- Bckp\RabbitMQ\Diagnostics\BarPanel
115122
```
116123

117124
### Declaring Queues and Exchanges
@@ -154,7 +161,7 @@ services.neon:
154161

155162
```neon
156163
services:
157-
- TestQueue(@Mallgroup\RabbitMQ\Client::getProducer(testProducer))
164+
- TestQueue(@Bckp\RabbitMQ\Client::getProducer(testProducer))
158165
```
159166

160167
TestQueue.php:
@@ -164,7 +171,7 @@ TestQueue.php:
164171

165172
declare(strict_types=1);
166173

167-
use Mallgroup\RabbitMQ\Producer\Producer;
174+
use Bckp\RabbitMQ\Producer\Producer;
168175

169176
final class TestQueue
170177
{
@@ -196,7 +203,7 @@ final class TestQueue
196203

197204
Bunny does not support well producers that run a long time but send the message only once in a long period. Producers often drop connection in the middle but bunny have no idea about it (stream is closed) and if you try to write some data, an exception will be thrown about broken connection.
198205
Drawback: you must call heartbeat by yourself.
199-
In the example below, you can see that Connection::sendHearbeat() is callen in every single cycle - that is not a problem as internally, `Mallgroup\rabbitmq` will actually let you send the heartbeat to rabbitmq only once per 1 second.
206+
In the example below, you can see that Connection::sendHearbeat() is callen in every single cycle - that is not a problem as internally, `Bckp\RabbitMQ` will actually let you send the heartbeat to rabbitmq only once per 1 second.
200207

201208
LongRunningTestQueue.php:
202209

@@ -205,7 +212,7 @@ LongRunningTestQueue.php:
205212

206213
declare(strict_types=1);
207214

208-
use Mallgroup\RabbitMQ\Producer\Producer;
215+
use Bckp\RabbitMQ\Producer\Producer;
209216

210217
final class LongRunningTestQueue
211218
{
@@ -270,7 +277,7 @@ TestConsumer.php
270277
declare(strict_types=1);
271278

272279
use Bunny\Message;
273-
use Mallgroup\RabbitMQ\Consumer\IConsumer;
280+
use Bckp\RabbitMQ\Consumer\IConsumer;
274281

275282
final class TestConsumer implements IConsumer
276283
{
@@ -303,7 +310,7 @@ TestBulkConsumer.php
303310
declare(strict_types=1);
304311

305312
use Bunny\Message;
306-
use Mallgroup\RabbitMQ\Consumer\IConsumer;
313+
use Bckp\RabbitMQ\Consumer\IConsumer;
307314

308315
final class TestConsumer
309316
{

.github/workflows/main.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
name: "Quality assurance"
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v4
1919
- uses: shivammathur/setup-php@v2
2020
with:
2121
php-version: 8.0
@@ -28,7 +28,7 @@ jobs:
2828
name: PHPStan
2929
runs-on: ubuntu-latest
3030
steps:
31-
- uses: actions/checkout@v2
31+
- uses: actions/checkout@v4
3232
- uses: shivammathur/setup-php@v2
3333
with:
3434
php-version: 8.0
@@ -41,7 +41,7 @@ jobs:
4141
name: Psalm
4242
runs-on: ubuntu-latest
4343
steps:
44-
- uses: actions/checkout@v2
44+
- uses: actions/checkout@v4
4545
- uses: shivammathur/setup-php@v2
4646
with:
4747
php-version: 8.0
@@ -54,13 +54,13 @@ jobs:
5454
runs-on: ubuntu-latest
5555
strategy:
5656
matrix:
57-
php: [ '8.0', '8.1', '8.2' ]
57+
php: [ '8.0', '8.1', '8.2', '8.3' ]
5858

5959
fail-fast: false
6060

6161
name: PHP ${{ matrix.php }} tests
6262
steps:
63-
- uses: actions/checkout@v2
63+
- uses: actions/checkout@v4
6464
- uses: shivammathur/setup-php@v2
6565
with:
6666
php-version: ${{ matrix.php }}
@@ -74,7 +74,7 @@ jobs:
7474
runs-on: ubuntu-latest
7575
needs: [tests]
7676
steps:
77-
- uses: actions/checkout@v2
77+
- uses: actions/checkout@v4
7878
- uses: shivammathur/setup-php@v2
7979
with:
8080
php-version: 8.0

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ install:
99
qa: phpstan cs
1010

1111
cs:
12-
vendor/bin/phpcs --standard=vendor/gamee/php-code-checker-rules/ruleset.xml --extensions=php,phpt --tab-width=4 --ignore=temp -sp src
12+
composer phpcs
1313

1414
csf:
15-
vendor/bin/phpcbf --standard=vendor/gamee/php-code-checker-rules/ruleset.xml --extensions=php,phpt --tab-width=4 --ignore=temp -sp src
15+
composer fix-style
1616

1717
phpstan:
1818
vendor/bin/phpstan analyse src

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "mallgroup/rabbitmq",
2+
"name": "bckp/rabbitmq",
33
"description": "Nette extension for RabbitMQ (using BunnyPHP)",
44
"type": "library",
55
"license": "MIT",
@@ -26,12 +26,12 @@
2626
],
2727
"autoload": {
2828
"psr-4": {
29-
"Mallgroup\\RabbitMQ\\": "src/"
29+
"Bckp\\RabbitMQ\\": "src/"
3030
}
3131
},
3232
"autoload-dev": {
3333
"psr-4": {
34-
"Mallgroup\\RabbitMQ\\Tests\\": "tests"
34+
"Bckp\\RabbitMQ\\Tests\\": "tests"
3535
}
3636
},
3737
"require": {

docker/docker-compose.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
version: '3.3'
2+
3+
services:
4+
app:
5+
image: "trafex/php-nginx"
6+
container_name: nette-rabbit
7+
ports:
8+
- "8088:80"
9+
volumes:
10+
- ../src.:/var/www/html
11+
links:
12+
- rabbitmq
13+
depends_on:
14+
- rabbitmq
15+
stdin_open: true
16+
tty: true
17+
18+
rabbitmq:
19+
image: "rabbitmq:3.11.19-management"
20+
container_name: rabbit
21+
environment:
22+
RABBITMQ_ERLANG_COOKIE: "uTVS3R2GmZJWN3rQ7zWM"
23+
RABBITMQ_DEFAULT_USER: "guest"
24+
RABBITMQ_DEFAULT_PASS: "guest"
25+
RABBITMQ_DEFAULT_VHOST: "/"
26+
ports:
27+
- "15672:15672"
28+
volumes:
29+
- ./docker/etc/rabbitmq/enabled_plugins:/etc/rabbitmq/enabled_plugins
30+
dns:
31+
- 10.1.17.211
32+
- 172.26.1.227
33+
labels:
34+
NAME: "rabbitmq"

src/AbstractDataBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Mallgroup\RabbitMQ;
5+
namespace Bckp\RabbitMQ;
66

77
abstract class AbstractDataBag
88
{

src/Client.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
declare(strict_types=1);
44

5-
namespace Mallgroup\RabbitMQ;
5+
namespace Bckp\RabbitMQ;
66

7-
use Mallgroup\RabbitMQ\Producer\Exception\ProducerFactoryException;
8-
use Mallgroup\RabbitMQ\Producer\IProducer;
9-
use Mallgroup\RabbitMQ\Producer\ProducerFactory;
7+
use Bckp\RabbitMQ\Producer\Exception\ProducerFactoryException;
8+
use Bckp\RabbitMQ\Producer\IProducer;
9+
use Bckp\RabbitMQ\Producer\ProducerFactory;
1010

1111
/**
1212
* This package uses composer library bunny/bunny. For more information,

src/Connection/Api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Mallgroup\RabbitMQ\Connection;
5+
namespace Bckp\RabbitMQ\Connection;
66

77
class Api implements IApi
88
{

src/Connection/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
declare(strict_types=1);
44

5-
namespace Mallgroup\RabbitMQ\Connection;
5+
namespace Bckp\RabbitMQ\Connection;
66

77
use Bunny\Client as BunnyClient;
88
use Bunny\ClientStateEnum;
99
use Bunny\Constants;
1010
use Bunny\Exception\BunnyException;
1111
use Bunny\Exception\ClientException;
1212
use Bunny\Protocol;
13-
use Mallgroup\RabbitMQ\Connection\Exception\WaitTimeoutException;
13+
use Bckp\RabbitMQ\Connection\Exception\WaitTimeoutException;
1414
use Nette\Utils\Strings;
1515
use function time;
1616

src/Connection/Connection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
declare(strict_types=1);
44

5-
namespace Mallgroup\RabbitMQ\Connection;
5+
namespace Bckp\RabbitMQ\Connection;
66

77
use Bunny\Channel;
88
use Bunny\Exception\ClientException;
9-
use Mallgroup\RabbitMQ\Connection\Exception\ConnectionException;
9+
use Bckp\RabbitMQ\Connection\Exception\ConnectionException;
1010
use function in_array;
1111
use function max;
1212
use function time;

0 commit comments

Comments
 (0)