| @@ 22-59 (lines=38) @@ | ||
| 19 | use PhpAmqpLib\Connection\AMQPLazyConnection; |
|
| 20 | use Psr\Log\LoggerInterface; |
|
| 21 | ||
| 22 | class Subscriber extends DomainSubscriber |
|
| 23 | { |
|
| 24 | /** |
|
| 25 | * Subscriber constructor. |
|
| 26 | * @param string $host |
|
| 27 | * @param int $port |
|
| 28 | * @param string $user |
|
| 29 | * @param string $password |
|
| 30 | * @param string $vHost |
|
| 31 | * @param string $exchangeName |
|
| 32 | * @param string $queueName |
|
| 33 | * @param BindConfig $bindConfig |
|
| 34 | * @param LoggerInterface $logger |
|
| 35 | */ |
|
| 36 | public function __construct( |
|
| 37 | $host, |
|
| 38 | $port, |
|
| 39 | $user, |
|
| 40 | $password, |
|
| 41 | $vHost, |
|
| 42 | $exchangeName, |
|
| 43 | $queueName, |
|
| 44 | BindConfig $bindConfig, |
|
| 45 | LoggerInterface $logger |
|
| 46 | ) |
|
| 47 | { |
|
| 48 | $queueReader = new QueueReader( |
|
| 49 | new AMQPLazyConnection($host, $port, $user, $password, $vHost), |
|
| 50 | new QueueConfig($queueName, false, true, false, false), |
|
| 51 | new ExchangeConfig($exchangeName, 'topic', false, true, false), |
|
| 52 | $bindConfig, |
|
| 53 | new ConsumeConfig(false, false, false, false), |
|
| 54 | new MessageHandler(new JSONDomainEventFactory()), |
|
| 55 | $logger |
|
| 56 | ); |
|
| 57 | parent::__construct($queueReader, $logger); |
|
| 58 | } |
|
| 59 | } |
|
| @@ 22-57 (lines=36) @@ | ||
| 19 | use PhpAmqpLib\Connection\AMQPLazyConnection; |
|
| 20 | use Psr\Log\LoggerInterface; |
|
| 21 | ||
| 22 | class Consumer extends DomainConsumer |
|
| 23 | { |
|
| 24 | /** |
|
| 25 | * Consumer constructor. |
|
| 26 | * @param string $host |
|
| 27 | * @param int $port |
|
| 28 | * @param string $user |
|
| 29 | * @param string $password |
|
| 30 | * @param string $vHost |
|
| 31 | * @param string $exchangeName |
|
| 32 | * @param string $queueName |
|
| 33 | * @param LoggerInterface $logger |
|
| 34 | */ |
|
| 35 | public function __construct( |
|
| 36 | $host, |
|
| 37 | $port, |
|
| 38 | $user, |
|
| 39 | $password, |
|
| 40 | $vHost, |
|
| 41 | $exchangeName, |
|
| 42 | $queueName, |
|
| 43 | LoggerInterface $logger |
|
| 44 | ) |
|
| 45 | { |
|
| 46 | $queueReader = new QueueReader( |
|
| 47 | new AMQPLazyConnection($host, $port, $user, $password, $vHost), |
|
| 48 | new QueueConfig($queueName, false, true, false, false), |
|
| 49 | new ExchangeConfig($exchangeName, 'fanout', false, true, false), |
|
| 50 | new BindConfig(), |
|
| 51 | new ConsumeConfig(false, false, false, false), |
|
| 52 | new MessageHandler(new JSONTaskFactory()), |
|
| 53 | $logger |
|
| 54 | ); |
|
| 55 | parent::__construct($queueReader); |
|
| 56 | } |
|
| 57 | } |
|