/**
  * @test
  */
 public function handle_should_use_existing_headers()
 {
     $table = new AMQPTable();
     $exceptionMessage = "Fatal error";
     $exception = new Exception($exceptionMessage);
     $payloadMessage = new Message();
     $amqpMessage = $this->prophesize(AMQPMessage::class);
     $amqpMessage->has('application_headers')->willReturn(true);
     $amqpMessage->get('application_headers')->willReturn($table);
     $amqpMessage->set('application_headers', $table)->shouldBeCalled();
     $this->client->sendMessage($amqpMessage->reveal(), self::CONSUMER_IDENTIFICATION)->shouldBeCalled();
     $exception = new ConsumerContainerException($this->consumerContainer->reveal(), $amqpMessage->reveal(), $payloadMessage, $exception);
     $this->handler->handle($exception);
 }
 /**
  * {@inheritdoc}
  */
 public function handle(ConsumerContainerException $ex)
 {
     $genericMessage = $ex->getPayloadMessage();
     $routingKey = $ex->getConsumerContainer()->getConsumerIdentification();
     $message = $ex->getAmqpMessage();
     $table = $this->getHeaders($message);
     $nativeData = $table->getNativeData();
     if (!isset($nativeData['type'])) {
         $table->set('type', $genericMessage->getRoutingKey(), AMQPTable::T_STRING_LONG);
     }
     if (!isset($nativeData['routing'])) {
         $table->set('routing', $routingKey, AMQPTable::T_STRING_LONG);
     }
     $message->set('application_headers', $table);
     $this->client->sendMessage($message, $routingKey);
 }