/** * @test */ public function it_logs_messages_when_rejecting_a_message() { $context = []; $context['correlation_id'] = new StringLiteral('my-correlation-id-123'); $this->logger->expects($this->at(0))->method('info')->with('received message with content-type application/vnd.cultuurnet.udb3-events.dummy-event+json', $context); $this->logger->expects($this->at(1))->method('error')->with('Deserializerlocator error', $context + ['exception' => new \InvalidArgumentException('Deserializerlocator error')]); $this->logger->expects($this->at(2))->method('info')->with('message rejected', $context); $this->deserializerLocator->expects($this->once())->method('getDeserializerForContentType')->with(new StringLiteral('application/vnd.cultuurnet.udb3-events.dummy-event+json'))->willThrowException(new \InvalidArgumentException('Deserializerlocator error')); $this->channel->expects($this->once())->method('basic_reject')->with('my-delivery-tag'); $messageProperties = ['content_type' => 'application/vnd.cultuurnet.udb3-events.dummy-event+json', 'correlation_id' => 'my-correlation-id-123']; $messageBody = ''; $message = new AMQPMessage($messageBody, $messageProperties); $message->delivery_info['channel'] = $this->channel; $message->delivery_info['delivery_tag'] = 'my-delivery-tag'; $this->eventBusForwardingConsumer->consume($message); }
/** * @param StringLiteral $exchange * @param StringLiteral $queue * @return EventBusForwardingConsumer */ public function create(StringLiteral $exchange, StringLiteral $queue) { $eventBusForwardingConsumer = new EventBusForwardingConsumer($this->connection, $this->eventBus, $this->deserializerLocator, $this->consumerTag, $exchange, $queue, $this->executionDelay->toNative()); $eventBusForwardingConsumer->setLogger($this->logger); return $eventBusForwardingConsumer; }