public interface UnitOfWork
Exchange
which allows the use of
Synchronization
hooks. This object might map one-to-one with a transaction in JPA or Spring; or might not.Modifier and Type | Field and Description |
---|---|
static String |
MDC_BREADCRUMB_ID |
static String |
MDC_CAMEL_CONTEXT_ID |
static String |
MDC_CORRELATION_ID |
static String |
MDC_EXCHANGE_ID |
static String |
MDC_MESSAGE_ID |
static String |
MDC_ROUTE_ID |
static String |
MDC_STEP_ID |
static String |
MDC_TRANSACTION_KEY |
Modifier and Type | Method and Description |
---|---|
void |
addSynchronization(Synchronization synchronization)
Adds a synchronization hook
|
void |
afterProcess(Processor processor,
Exchange exchange,
AsyncCallback callback,
boolean doneSync)
Strategy for work to be executed after the processing
This requires
isBeforeAfterProcess() returns true to be enabled. |
void |
afterRoute(Exchange exchange,
Route route)
Invoked when this unit of work is done being routed by the given route.
|
AsyncCallback |
beforeProcess(Processor processor,
Exchange exchange,
AsyncCallback callback)
Strategy for work to be executed before processing.
|
void |
beforeRoute(Exchange exchange,
Route route)
Invoked when this unit of work is about to be routed by the given route.
|
void |
beginTransactedBy(Object key)
Mark this UnitOfWork as being transacted by the given transaction key.
|
boolean |
containsSynchronization(Synchronization synchronization)
Checks if the passed synchronization hook is already part of this unit of work.
|
UnitOfWork |
createChildUnitOfWork(Exchange childExchange)
Create a child unit of work, which is associated to this unit of work as its parent.
|
void |
done(Exchange exchange)
Invoked when this unit of work has been completed, whether it has failed or completed
|
void |
endTransactedBy(Object key)
Mark this UnitOfWork as not transacted anymore by the given transaction definition.
|
Message |
getOriginalInMessage()
Gets the original IN
Message this Unit of Work was started with. |
Route |
getRoute()
Gets the
Route that this UnitOfWork currently is being routed through. |
void |
handoverSynchronization(Exchange target)
Handover all the registered synchronizations to the target
Exchange . |
void |
handoverSynchronization(Exchange target,
Predicate<Synchronization> filter)
Handover all the registered synchronizations to the target
Exchange . |
boolean |
isBeforeAfterProcess()
Whether the unit of work should call the before/after process methods or not.
|
boolean |
isTransacted()
Are we transacted?
|
boolean |
isTransactedBy(Object key)
Are we already transacted by the given transaction key?
|
boolean |
onPrepare(Exchange exchange)
Prepares this unit of work with the given input
Exchange |
Route |
popRoute()
When finished being routed under the current
Route it should be removed. |
void |
pushRoute(Route route)
Pushes the
Route that this UnitOfWork currently is being routed through. |
void |
removeSynchronization(Synchronization synchronization)
Removes a synchronization hook
|
void |
reset()
Clears the unit of work from user data, so it may be reused.
|
void |
setParentUnitOfWork(UnitOfWork parentUnitOfWork)
Sets the parent unit of work.
|
static final String MDC_BREADCRUMB_ID
static final String MDC_EXCHANGE_ID
static final String MDC_MESSAGE_ID
static final String MDC_CORRELATION_ID
static final String MDC_ROUTE_ID
static final String MDC_STEP_ID
static final String MDC_CAMEL_CONTEXT_ID
static final String MDC_TRANSACTION_KEY
void reset()
boolean onPrepare(Exchange exchange)
Exchange
exchange
- the exchangevoid addSynchronization(Synchronization synchronization)
synchronization
- the hookvoid removeSynchronization(Synchronization synchronization)
synchronization
- the hookboolean containsSynchronization(Synchronization synchronization)
synchronization
- the hookvoid handoverSynchronization(Exchange target)
Exchange
.
This is used when a route turns into asynchronous and the Exchange
that is continued and
routed in the async thread should do the on completion callbacks instead of the original synchronous thread.target
- the target exchangevoid handoverSynchronization(Exchange target, Predicate<Synchronization> filter)
Exchange
.
This is used when a route turns into asynchronous and the Exchange
that is continued and
routed in the async thread should do the on completion callbacks instead of the original synchronous thread.target
- the target exchangefilter
- optional filter to only handover if filter returns truevoid done(Exchange exchange)
exchange
- the current exchangevoid beforeRoute(Exchange exchange, Route route)
exchange
- the current exchangeroute
- the routevoid afterRoute(Exchange exchange, Route route)
exchange
- the current exchangeroute
- the routeMessage getOriginalInMessage()
Message
this Unit of Work was started with.
The original message is only returned if the option
RuntimeConfiguration.isAllowUseOriginalMessage()
is enabled. If its disabled an
IllegalStateException is thrown.Message
, or null if using original message is disabled.boolean isTransacted()
boolean isTransactedBy(Object key)
key
- the transaction keyvoid beginTransactedBy(Object key)
endTransactedBy(Object)
method using the same key.key
- the transaction keyvoid endTransactedBy(Object key)
key
- the transaction keyRoute getRoute()
Route
that this UnitOfWork
currently is being routed through.
Notice that an Exchange
can be routed through multiple routes and thus the Route
can change over time.void pushRoute(Route route)
Route
that this UnitOfWork
currently is being routed through.
Notice that an Exchange
can be routed through multiple routes and thus the Route
can change over time.route
- the routeRoute popRoute()
Route
it should be removed.boolean isBeforeAfterProcess()
AsyncCallback beforeProcess(Processor processor, Exchange exchange, AsyncCallback callback)
isBeforeAfterProcess()
returns true to be enabled.processor
- the processor to be executedexchange
- the current exchangecallback
- the callbackvoid afterProcess(Processor processor, Exchange exchange, AsyncCallback callback, boolean doneSync)
isBeforeAfterProcess()
returns true to be enabled.processor
- the processor executedexchange
- the current exchangecallback
- the callback useddoneSync
- whether the process was done synchronously or asynchronouslyUnitOfWork createChildUnitOfWork(Exchange childExchange)
childExchange
- the child exchangevoid setParentUnitOfWork(UnitOfWork parentUnitOfWork)
parentUnitOfWork
- the parentApache Camel