Skip to content

Commit dccfaa8

Browse files
refactoring rabbitmq connection
1 parent dcaa503 commit dccfaa8

12 files changed

+49
-31
lines changed

config/services.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ services:
2424
shared: true
2525

2626
App\Infrastructure\Rabbitmq\RabbitmqConnectionInterface: '@App\Infrastructure\Rabbitmq\RabbitmqConnection'
27+
2728
App\Infrastructure\Rabbitmq\RabbitmqConnection:
2829
public: true
2930
shared: true
31+
arguments:
32+
- '@rabbitmq.connection'
33+
34+
rabbitmq.connection:
35+
class: PhpAmqpLib\Connection\AMQPStreamConnection
36+
factory: [ 'App\Infrastructure\Rabbitmq\RabbitmqConnectionFactory', 'createConnection' ]
37+
shared: true

src/Infrastructure/Rabbitmq/Consumer/DirectConsumerCommand.php

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

55
namespace App\Infrastructure\Rabbitmq\Consumer;
66

7-
use App\Infrastructure\Rabbitmq\RabbitmqConnection;
7+
use App\Infrastructure\Rabbitmq\RabbitmqConnectionInterface;
88
use Symfony\Component\Console\Attribute\AsCommand;
99
use Symfony\Component\Console\Command\Command;
1010
use Symfony\Component\Console\Input\InputInterface;
@@ -21,7 +21,7 @@ class DirectConsumerCommand extends Command
2121
private const EXCHANGE_NAME = 'e.direct';
2222

2323
public function __construct(
24-
protected readonly RabbitmqConnection $rabbitmqConnection,
24+
protected readonly RabbitmqConnectionInterface $rabbitmqConnection,
2525
?string $name = null)
2626
{
2727
parent::__construct($name);

src/Infrastructure/Rabbitmq/Consumer/FanoutConsumerCommand.php

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

55
namespace App\Infrastructure\Rabbitmq\Consumer;
66

7-
use App\Infrastructure\Rabbitmq\RabbitmqConnection;
7+
use App\Infrastructure\Rabbitmq\RabbitmqConnectionInterface;
88
use Symfony\Component\Console\Attribute\AsCommand;
99
use Symfony\Component\Console\Command\Command;
1010
use Symfony\Component\Console\Input\InputInterface;
@@ -21,7 +21,7 @@ class FanoutConsumerCommand extends Command
2121
private const QUEUE_NAME = 'q.events-fanout.1';
2222

2323
public function __construct(
24-
protected readonly RabbitmqConnection $rabbitmqConnection,
24+
protected readonly RabbitmqConnectionInterface $rabbitmqConnection,
2525
?string $name = null)
2626
{
2727
parent::__construct($name);

src/Infrastructure/Rabbitmq/Consumer/HeaderConsumerCommand.php

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

55
namespace App\Infrastructure\Rabbitmq\Consumer;
66

7-
use App\Infrastructure\Rabbitmq\RabbitmqConnection;
7+
use App\Infrastructure\Rabbitmq\RabbitmqConnectionInterface;
88
use PhpAmqpLib\Wire\AMQPTable;
99
use Symfony\Component\Console\Attribute\AsCommand;
1010
use Symfony\Component\Console\Command\Command;
@@ -22,7 +22,7 @@ class HeaderConsumerCommand extends Command
2222
private const QUEUE_NAME = 'q.events-header';
2323

2424
public function __construct(
25-
protected readonly RabbitmqConnection $rabbitmqConnection,
25+
protected readonly RabbitmqConnectionInterface $rabbitmqConnection,
2626
?string $name = null)
2727
{
2828
parent::__construct($name);

src/Infrastructure/Rabbitmq/Consumer/SecondFanoutConsumerCommand.php

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

55
namespace App\Infrastructure\Rabbitmq\Consumer;
66

7-
use App\Infrastructure\Rabbitmq\RabbitmqConnection;
7+
use App\Infrastructure\Rabbitmq\RabbitmqConnectionInterface;
88
use Symfony\Component\Console\Attribute\AsCommand;
99
use Symfony\Component\Console\Command\Command;
1010
use Symfony\Component\Console\Input\InputInterface;
@@ -21,7 +21,7 @@ class SecondFanoutConsumerCommand extends Command
2121
private const QUEUE_NAME = 'q.events-fanout.2';
2222

2323
public function __construct(
24-
protected readonly RabbitmqConnection $rabbitmqConnection,
24+
protected readonly RabbitmqConnectionInterface $rabbitmqConnection,
2525
?string $name = null)
2626
{
2727
parent::__construct($name);

src/Infrastructure/Rabbitmq/Consumer/TopicConsumerCommand.php

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

55
namespace App\Infrastructure\Rabbitmq\Consumer;
66

7-
use App\Infrastructure\Rabbitmq\RabbitmqConnection;
7+
use App\Infrastructure\Rabbitmq\RabbitmqConnectionInterface;
88
use Symfony\Component\Console\Attribute\AsCommand;
99
use Symfony\Component\Console\Command\Command;
1010
use Symfony\Component\Console\Input\InputInterface;
@@ -21,7 +21,7 @@ class TopicConsumerCommand extends Command
2121
private const QUEUE_NAME = 'q.events-topic';
2222

2323
public function __construct(
24-
protected readonly RabbitmqConnection $rabbitmqConnection,
24+
protected readonly RabbitmqConnectionInterface $rabbitmqConnection,
2525
?string $name = null)
2626
{
2727
parent::__construct($name);

src/Infrastructure/Rabbitmq/Producer/DirectProducerCommand.php

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

55
namespace App\Infrastructure\Rabbitmq\Producer;
66

7-
use App\Infrastructure\Rabbitmq\RabbitmqConnection;
7+
use App\Infrastructure\Rabbitmq\RabbitmqConnectionInterface;
88
use PhpAmqpLib\Message\AMQPMessage;
99
use Symfony\Component\Console\Attribute\AsCommand;
1010
use Symfony\Component\Console\Command\Command;
@@ -21,7 +21,7 @@ class DirectProducerCommand extends Command
2121
private const EXCHANGE_NAME = 'e.direct';
2222

2323
public function __construct(
24-
protected readonly RabbitmqConnection $rabbitmqConnection,
24+
protected readonly RabbitmqConnectionInterface $rabbitmqConnection,
2525
string $name = null
2626
) {
2727
parent::__construct($name);

src/Infrastructure/Rabbitmq/Producer/FanoutProducerCommand.php

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

55
namespace App\Infrastructure\Rabbitmq\Producer;
66

7-
use App\Infrastructure\Rabbitmq\RabbitmqConnection;
7+
use App\Infrastructure\Rabbitmq\RabbitmqConnectionInterface;
88
use PhpAmqpLib\Message\AMQPMessage;
99
use Symfony\Component\Console\Attribute\AsCommand;
1010
use Symfony\Component\Console\Command\Command;
@@ -21,7 +21,7 @@ class FanoutProducerCommand extends Command
2121
private const EXCHANGE_NAME = 'e.fanout';
2222

2323
public function __construct(
24-
protected readonly RabbitmqConnection $rabbitmqConnection,
24+
protected readonly RabbitmqConnectionInterface $rabbitmqConnection,
2525
string $name = null
2626
) {
2727
parent::__construct($name);

src/Infrastructure/Rabbitmq/Producer/HeaderProducerCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace App\Infrastructure\Rabbitmq\Producer;
66

77
use App\Infrastructure\Rabbitmq\RabbitmqConnection;
8+
use App\Infrastructure\Rabbitmq\RabbitmqConnectionInterface;
89
use PhpAmqpLib\Message\AMQPMessage;
910
use PhpAmqpLib\Wire\AMQPTable;
1011
use Symfony\Component\Console\Attribute\AsCommand;
@@ -22,7 +23,7 @@ class HeaderProducerCommand extends Command
2223
private const EXCHANGE_NAME = 'e.header';
2324

2425
public function __construct(
25-
protected readonly RabbitmqConnection $rabbitmqConnection,
26+
protected readonly RabbitmqConnectionInterface $rabbitmqConnection,
2627
string $name = null
2728
) {
2829
parent::__construct($name);

src/Infrastructure/Rabbitmq/Producer/TopicProducerCommand.php

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

55
namespace App\Infrastructure\Rabbitmq\Producer;
66

7-
use App\Infrastructure\Rabbitmq\RabbitmqConnection;
7+
use App\Infrastructure\Rabbitmq\RabbitmqConnectionInterface;
88
use PhpAmqpLib\Message\AMQPMessage;
99
use Symfony\Component\Console\Attribute\AsCommand;
1010
use Symfony\Component\Console\Command\Command;
@@ -21,7 +21,7 @@ class TopicProducerCommand extends Command
2121
private const EXCHANGE_NAME = 'e.topic';
2222

2323
public function __construct(
24-
protected readonly RabbitmqConnection $rabbitmqConnection,
24+
protected readonly RabbitmqConnectionInterface $rabbitmqConnection,
2525
string $name = null
2626
) {
2727
parent::__construct($name);

0 commit comments

Comments
 (0)