### Question:
DeadLetterMessageRecoverer implements MessageRecoverer { @Override public void recover(final Message message, final Throwable cause) { Map<String, Object> headers = message.getMessageProperties().getHeaders(); headers.put("x-exception-stacktrace", ExceptionUtils.getFullStackTrace(cause)); headers.put("x-exception-message", ExceptionUtils.getMessage(cause)); headers.put("x-exception-root-cause-message", ExceptionUtils.getRootCauseMessage(cause)); headers.put("x-original-exchange", message.getMessageProperties().getReceivedExchange()); headers.put("x-original-routingKey", message.getMessageProperties().getReceivedRoutingKey()); headers.put("x-original-queue", message.getMessageProperties().getConsumerQueue()); headers.put("x-recover-time", new Date().toString()); String deadLetterExchangeName = rabbitmqProperties.getDeadLetterConfig().getDeadLetterExchange().getName(); String deadLetterRoutingKey = rabbitmqProperties.getDeadLetterConfig().createDeadLetterQueueName(message.getMessageProperties().getConsumerQueue()); headers.put("x-dead-letter-exchange", deadLetterExchangeName); headers.put("x-dead-letter-queue", deadLetterRoutingKey); if(headers.containsKey("correlation-id")) { message.getMessageProperties().setCorrelationId((String) headers.get("correlation-id")); } headers.putAll(loadAdditionalHeaders(message, cause)); for (MessageExceptionHandler messageExceptionHandler : messageExceptionHandlers) { try { messageExceptionHandler.handle(message, cause); } catch (Exception e) { log.error("Exception occurred while processing '{}' message exception handler.", messageExceptionHandler, e); } } this.errorTemplate.send(deadLetterExchangeName, deadLetterRoutingKey, message); log.warn("Republishing failed message to exchange '{}', routing key '{}', message {{}} , cause {}", deadLetterExchangeName, deadLetterRoutingKey, message, cause); }  @Override void recover(final Message message, final Throwable cause);  }### Answer:
@Test public void deadLetterMessageRecovererTest() { doNothing().when(errorTemplate).send(anyString(), anyString(), any(Message.class)); deadLetterMessageRecoverer.recover(message, cause); verify(errorTemplate, times(1)).send(anyString(), anyString(), any(Message.class)); Map<String, Object> headers = message.getMessageProperties().getHeaders(); Assert.assertTrue(headers.containsKey("x-exception-stacktrace")); Assert.assertTrue(headers.containsKey("x-exception-message")); Assert.assertTrue(headers.containsKey("x-exception-root-cause-message")); Assert.assertTrue(headers.containsKey("x-original-exchange")); Assert.assertTrue(headers.containsKey("x-original-routingKey")); Assert.assertTrue(headers.containsKey("x-original-queue")); Assert.assertTrue(headers.containsKey("x-recover-time")); Assert.assertTrue(headers.containsKey("x-dead-letter-exchange")); Assert.assertTrue(headers.containsKey("x-dead-letter-queue")); Assert.assertThat(headers.get("x-exception-message"), equalTo("RuntimeException: Some Exception")); Assert.assertThat(headers.get("x-exception-root-cause-message"), equalTo("RuntimeException: Some Root Cause")); }