How to set transaction timeout less than 1 sec?

56 views Asked by At

As per the org.apache.geronimo.transaction.manager.TransactionTimer, following is the implementation:

package org.apache.geronimo.transaction.manager;
import java.security.AccessController;
import java.security.PrivilegedAction;
public class TransactionTimer {
  private static volatile long currentTime;
  public TransactionTimer() {}
  public static long getCurrentTime() {
    return currentTime;
  }
  static {
    AccessController.doPrivileged(new PrivilegedAction() {
      public Object run() {
        TransactionTimer.CurrentTime tm = new TransactionTimer.CurrentTime();
        tm.setDaemon(true);
        tm.start();
        return null;
      }
    });
  }
  private static class CurrentTime extends Thread {
    protected CurrentTime() {
      TransactionTimer.currentTime = System.currentTimeMillis();
      this.setContextClassLoader((ClassLoader) null);
    }
    public void run() {
      while (true) {
        TransactionTimer.currentTime = System.currentTimeMillis();
        try {
          * Thread.sleep(1000 L);*
        } catch (InterruptedException var2) {
          ;
        }
      }
    }
  }
}


Which shows that the currentTime is always incremented by 1 sec, and so the lib do not support a timeout less than 1 sec. How I can set timeout less than 1 sec ?

    TransactionImpl(Xid xid, TransactionManagerImpl txManager, long transactionTimeoutMilliseconds) throws SystemException {
        this.syncList = new ArrayList(5);
        this.interposedSyncList = new ArrayList(3);
        this.resourceManagers = new LinkedList();
        this.activeXaResources = new IdentityHashMap(3);
        this.suspendedXaResources = new IdentityHashMap(3);
        this.status = 6;
        this.resources = new HashMap();
        this.txManager = txManager;
        this.xid = xid;
        this.timeout = transactionTimeoutMilliseconds + TransactionTimer.getCurrentTime();

Didn't find any way to set a value less than 1 sec.

0

There are 0 answers