org.mule.work
Class ProcessingMuleEventWork
java.lang.Object
org.mule.work.AbstractMuleEventWork
org.mule.work.ProcessingMuleEventWork
- All Implemented Interfaces:
- Runnable, javax.resource.spi.work.Work
public class ProcessingMuleEventWork
- extends AbstractMuleEventWork
Implementation of AbstractMuleEventWork that executes a
MessageProcessor using this work's event. Instances of this class can be
used in a "fire and forget" fashion or the getResult(long, TimeUnit)
method can be used to wait for background processing to finish. For cases when
used in this latter manner, this class provides semmantics similar to
Future.get(long, TimeUnit) but with some differences around exception
handling, cancellation, etc (see getResult(long, TimeUnit)).
- Since:
- 3.5.0
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ProcessingMuleEventWork
public ProcessingMuleEventWork(MessageProcessor messageProcessor,
MuleEvent muleEvent)
doRun
protected void doRun()
- Invokes
MessageProcessor.process(MuleEvent) using
and AbstractMuleEventWork#event. if processing is
sucessful the result is stored in resultEvent or if it throws
exception, it will be stored in exception Storing the
result/exception allows getResult(long, TimeUnit) to return the
values
- Specified by:
doRun in class AbstractMuleEventWork
getResult
public MuleEvent getResult(long timeout,
TimeUnit timeUnit)
throws InterruptedException,
ResponseTimeoutException,
MuleException
- This method is useful for having a thread other than the one executing this
work waiting for the result being available. This is similar to
Future.get(long, TimeUnit) but with some significant differences,
mainly around the type of exceptions to be thrown and the fact that this work
cannot cancel itself
- Parameters:
timeout - time to wait before throwing ResponseTimeoutExceptiontimeUnit - the unit for the timeout
- Returns:
- a
MuleEvent once that doRun() finised successfuly
- Throws:
InterruptedException - if the calling thread is interrupted
ResponseTimeoutException - if the calling thread waiting time has
exceeded the timeout and doRun() hasn't yet finished
MuleException - if doRun() finished with exception. In that
case, the value captured in exception is thrown
Copyright © 2003–2014 MuleSoft, Inc.. All rights reserved.