public class ProcessingMuleEventWork extends AbstractMuleEventWork
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)).event| Constructor and Description |
|---|
ProcessingMuleEventWork(MessageProcessor messageProcessor,
MuleEvent muleEvent) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doRun()
|
MuleEvent |
getResult(long timeout,
TimeUnit timeUnit)
This method is useful for having a thread other than the one executing this
work waiting for the result being available.
|
getEvent, release, runpublic ProcessingMuleEventWork(MessageProcessor messageProcessor, MuleEvent muleEvent)
protected void doRun()
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
valuesdoRun in class AbstractMuleEventWorkpublic MuleEvent getResult(long timeout, TimeUnit timeUnit) throws InterruptedException, ResponseTimeoutException, MuleException
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 itselftimeout - time to wait before throwing ResponseTimeoutExceptiontimeUnit - the unit for the timeoutMuleEvent once that doRun() finised successfulyInterruptedException - if the calling thread is interruptedResponseTimeoutException - if the calling thread waiting time has
exceeded the timeout and doRun() hasn't yet finishedMuleException - if doRun() finished with exception. In that
case, the value captured in exception is thrownCopyright © 2003–2015 MuleSoft, Inc.. All rights reserved.