@PreDestroy
 public void stop() {
   try {
     messageAcker.stop();
     producerChannel.close();
     consumerChannel.close();
     clientConnection.close();
   } catch (IOException | TimeoutException e) {
     logger.error("Failed to close all RabbitMQ Client resources", e);
   }
 }
  @PostConstruct
  public void start() throws IOException, TimeoutException {
    // millis
    connectionFactory.setConnectionTimeout(1000);
    // seconds
    connectionFactory.setRequestedHeartbeat(4);
    // lyra reconnect logic
    Config config =
        new Config()
            .withRecoveryPolicy(
                new RecoveryPolicy().withMaxAttempts(-1).withInterval(Duration.seconds(1)))
            .withChannelListeners(this);

    ConnectionOptions connectionOptions =
        new ConnectionOptions(connectionFactory).withAddresses(rabbitmqHosts);
    connectionOptions.withUsername(username);
    connectionOptions.withPassword(password);
    // create single connection
    // clientConnection = connectionFactory.newConnection(Address.parseAddresses(rabbitmqHosts));
    clientConnection = Connections.create(connectionOptions, config);
    // create a seperate producer and a seperate consumer channel
    consumerChannel = clientConnection.createChannel();
    producerChannel = clientConnection.createChannel();
    // ensure the exchange is there
    consumerChannel.exchangeDeclare(exchangeName, "direct", true);
    if (ackType == BUFFERED) {
      messageAcker = new BufferingMessageAcker(consumerChannel);
    } else if (ackType == WRITE_BEHIND) {
      messageAcker = new WriteBehindMessageAcker(consumerChannel);
    } else if (ackType == ASYNC) {
      messageAcker = new AsyncMessageAcker(consumerChannel);
    } else {
      messageAcker = new DirectMessageAcker(consumerChannel);
    }
    messageAcker.start();
  }