private int fetch_reply_struct() {
    try {

      rows_num = rep_type.getField("out_columns_num").getInt(null);

    } catch (NoSuchFieldException | IllegalAccessException ex) {
      real_requester.tell(new DbmsLayerError(ex), ActorRef.noSender());
      return (-1);
    }

    try {
      lines_num = rep_type.getField("out_lines_num").getInt(null);
    } catch (NoSuchFieldException | IllegalAccessException ex) {

    }
    return (0);
  }
  @Override
  public void onReceive(Object message) {

    do {
      if (message instanceof QueryGenericArgument) {
        reincarnate((QueryGenericArgument) message);
        break;
      }

      if (message instanceof GetDbmsStatementReply) {
        Statement stmt = ((GetDbmsStatementReply) message).stmt;
        getSender()
            .tell(
                new DbmsExecuteStmtRequest(stmt, query, request_properties, autocommit), getSelf());
        break;
      }

      if (message instanceof GetDbmsPreparedStatementReply) {
        PreparedStatement p_stmt = ((GetDbmsPreparedStatementReply) message).p_stmt;

        try {

          for (int param_idx = 0; param_idx < values.size(); param_idx++)
            p_stmt.setObject(param_idx + 1, values.get(param_idx));

          getSender()
              .tell(
                  new DbmsExecutePrepStmtRequest(p_stmt, request_properties, autocommit),
                  getSelf());

        } catch (SQLException ex) {
          real_requester.tell(new DbmsLayerError(ex), getSelf());
          if (policy == DbmsLayerProvider.DeathPolicy.SUICIDE) getContext().stop(getSelf());
        }

        break;
      }

      if (message instanceof DBMSReply) {
        boolean has_result = false;
        DBMSReply dbms_result = (DBMSReply) message;
        ResultSet result = dbms_result.resultSet;
        Object output_obj = null, output_data = null;
        ArrayList<Object> result_list = new ArrayList<>();
        try {

          switch (dbms_result.request_mode) {
            case WRITE:
              output_data = dbms_result.ddl_retval;
              break;
            case READ_WRITE:
            case READ_ONLY:
              output_data = null;
          }
          if (result != null) {

            for (int cur_line = 0; cur_line < lines_num; cur_line++) {
              if (result.next()) {
                for (int cur_row = 0; cur_row < rows_num; cur_row++)
                  result_list.add(result.getObject(cur_row + 1));
              } else break;
            }

          } else result_list.add(dbms_result.ddl_retval);

          output_obj =
              rep_type
                  .getConstructor(Object[].class)
                  .newInstance(new Object[] {result_list.toArray()});

        } catch (SQLException ex) {
          if (has_result == false) output_obj = new DbmsRemoteDbError(ex);
          else output_obj = new DbmsOutputFormatError(ex);
        } catch (
            Exception
                ex) // (NoSuchMethodException | IllegalAccessException | InstantiationException |
        // InvocationTargetException ex)
        {
          output_obj =
              new DbmsLayerError(
                  ex,
                  " INPUT CLASS: "
                      + rep_type.getName()
                      + " OUT_DATA ARG LEN: "
                      + result_list.size());
        } finally {
          if (result != null) closeResult(result);

          real_requester.tell(output_obj, getSelf());
          if (policy == DbmsLayerProvider.DeathPolicy.SUICIDE) getContext().stop(getSelf());
        }
        break;
      }

      if (message instanceof DbmsWorkerCmdRequest) {
        dbms_actor.forward(message, getContext());
        break;
      }

      if (message instanceof DbmsWorkerCmdReply) {
        DbmsWorkerCmdReply reply = (DbmsWorkerCmdReply) message;

        if (reply.originalRequest != DbmsWorkerCmdRequest.Command.CLOSE_STMT)
          log.error("UNEXPECTED BEHAVIOUR");
        break;
      }

      if (message instanceof DbmsException) {
        real_requester.tell(message, getSelf());
        if (policy == DbmsLayerProvider.DeathPolicy.SUICIDE) getContext().stop(getSelf());
        break;
      }

      real_requester.tell(
          new DbmsLayerError(message.getClass().getName() + " UNHANDLED RECEIVED"), getSelf());
      if (policy == DbmsLayerProvider.DeathPolicy.SUICIDE) getContext().stop(getSelf());

    } while (false);
  }