@Override
 public void disconnect(ServerConsumer consumer, String queueName) {
   synchronized (connection.getLock()) {
     ((Link) consumer.getProtocolContext()).close();
     connection.flush();
   }
 }
  @Override
  public int sendMessage(ServerMessage message, ServerConsumer consumer, int deliveryCount) {

    ProtonPlugSender plugSender = (ProtonPlugSender) consumer.getProtocolContext();

    try {
      return plugSender.deliverMessage(message, deliveryCount);
    } catch (Exception e) {
      synchronized (connection.getLock()) {
        plugSender
            .getSender()
            .setCondition(new ErrorCondition(AmqpError.INTERNAL_ERROR, e.getMessage()));
        connection.flush();
      }
      throw new IllegalStateException("Can't deliver message " + e, e);
    }
  }