private void send(
     String exchangeName,
     String routingKey,
     final Message<?> requestMessage,
     CorrelationData correlationData) {
   if (this.amqpTemplate instanceof RabbitTemplate) {
     MessageConverter converter = ((RabbitTemplate) this.amqpTemplate).getMessageConverter();
     org.springframework.amqp.core.Message amqpMessage =
         MappingUtils.mapMessage(
             requestMessage, converter, getHeaderMapper(), getDefaultDeliveryMode());
     addDelayProperty(requestMessage, amqpMessage);
     ((RabbitTemplate) this.amqpTemplate)
         .send(exchangeName, routingKey, amqpMessage, correlationData);
   } else {
     this.amqpTemplate.convertAndSend(
         exchangeName,
         routingKey,
         requestMessage.getPayload(),
         message -> {
           getHeaderMapper()
               .fromHeadersToRequest(requestMessage.getHeaders(), message.getMessageProperties());
           return message;
         });
   }
 }
  private Message<?> sendAndReceive(
      String exchangeName,
      String routingKey,
      Message<?> requestMessage,
      CorrelationData correlationData) {
    Assert.isInstanceOf(
        RabbitTemplate.class,
        this.amqpTemplate,
        "RabbitTemplate implementation is required for publisher confirms");
    MessageConverter converter = ((RabbitTemplate) this.amqpTemplate).getMessageConverter();
    org.springframework.amqp.core.Message amqpMessage =
        MappingUtils.mapMessage(
            requestMessage, converter, getHeaderMapper(), getDefaultDeliveryMode());
    addDelayProperty(requestMessage, amqpMessage);
    org.springframework.amqp.core.Message amqpReplyMessage =
        ((RabbitTemplate) this.amqpTemplate)
            .sendAndReceive(exchangeName, routingKey, amqpMessage, correlationData);

    if (amqpReplyMessage == null) {
      return null;
    }
    return buildReplyMessage(converter, amqpReplyMessage);
  }