Example usage for javax.resource.spi.work WorkException START_TIMED_OUT

List of usage examples for javax.resource.spi.work WorkException START_TIMED_OUT

Introduction

In this page you can find the example usage for javax.resource.spi.work WorkException START_TIMED_OUT.

Prototype

String START_TIMED_OUT

To view the source code for javax.resource.spi.work WorkException START_TIMED_OUT.

Click Source Link

Document

Indicates start timeout expiration.

Usage

From source file:org.mule.work.WorkerContext.java

/**
 * Used by a Work executor in order to know if this work, which should be
 * accepted but not started has timed out. This method MUST be called prior to
 * retry the execution of a Work./*from  w w  w.j  av  a  2 s.c om*/
 * 
 * @return true if the Work has timed out and false otherwise.
 */
public synchronized boolean isTimedOut() {
    // A value of 0 means that the work never times out.
    // ??? really?
    if (0 == startTimeOut || startTimeOut == MuleWorkManager.INDEFINITE) {
        return false;
    }
    boolean isTimeout = acceptedTime + startTimeOut > 0
            && System.currentTimeMillis() > acceptedTime + startTimeOut;
    if (logger.isDebugEnabled()) {
        logger.debug(
                this + " accepted at " + acceptedTime + (isTimeout ? " has timed out." : " has not timed out. ")
                        + retryCount + " retries have been performed.");
    }
    if (isTimeout) {
        workException = new WorkRejectedException(this + " has timed out.", WorkException.START_TIMED_OUT);
        workListener.workRejected(new WorkEvent(this, WorkEvent.WORK_REJECTED, worker, workException));
        return true;
    }
    retryCount++;
    return isTimeout;
}