Esempio n. 1
0
  private void doRollback(
      final boolean clientFailed, final boolean lastMessageAsDelived, final Transaction theTx)
      throws Exception {
    boolean wasStarted = started;

    List<MessageReference> toCancel = new ArrayList<MessageReference>();

    for (ServerConsumer consumer : consumers.values()) {
      if (wasStarted) {
        consumer.setStarted(false);
      }

      toCancel.addAll(consumer.cancelRefs(clientFailed, lastMessageAsDelived, theTx));
    }

    for (MessageReference ref : toCancel) {
      ref.getQueue().cancel(theTx, ref);
    }

    if (wasStarted) {
      theTx.addOperation(
          new TransactionOperationAbstract() {

            public void afterRollback(Transaction tx) {
              for (ServerConsumer consumer : consumers.values()) {
                consumer.setStarted(true);
              }
            }
          });
    }

    theTx.rollback();
  }
Esempio n. 2
0
  private void doRollback(
      final boolean clientFailed, final boolean lastMessageAsDelived, final Transaction theTx)
      throws Exception {
    boolean wasStarted = started;

    List<MessageReference> toCancel = new ArrayList<MessageReference>();

    for (ServerConsumer consumer : consumers.values()) {
      if (wasStarted) {
        consumer.setStarted(false);
      }

      toCancel.addAll(consumer.cancelRefs(clientFailed, lastMessageAsDelived, theTx));
    }

    for (MessageReference ref : toCancel) {
      ref.getQueue().cancel(theTx, ref);
    }
    // if we failed don't restart as an attempt to deliver messages may be made before we actually
    // close the consumer
    if (wasStarted && !clientFailed) {
      theTx.addOperation(
          new TransactionOperationAbstract() {

            @Override
            public void afterRollback(Transaction tx) {
              for (ServerConsumer consumer : consumers.values()) {
                consumer.setStarted(true);
              }
            }
          });
    }

    theTx.rollback();
  }
Esempio n. 3
0
  private void setStarted(final boolean s) {
    Set<ServerConsumer> consumersClone = new HashSet<ServerConsumer>(consumers.values());

    for (ServerConsumer consumer : consumersClone) {
      consumer.setStarted(s);
    }

    started = s;
  }