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