Example usage for javax.resource.spi.work WorkRejectedException WorkRejectedException

List of usage examples for javax.resource.spi.work WorkRejectedException WorkRejectedException

Introduction

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

Prototype

public WorkRejectedException(String message, String errorCode) 

Source Link

Document

Constructs a new throwable with the specified detail message and an error code.

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.// w w  w . j av  a2  s.  co  m
 * 
 * @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;
}