|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface UnitOfWork
An object representing the unit of work processing an 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.
Method Summary | |
---|---|
void |
addSynchronization(Synchronization synchronization)
Adds a synchronization hook |
void |
afterProcess(Processor processor,
Exchange exchange,
AsyncCallback callback,
boolean doneSync)
Strategy for optional work to be executed after the processing |
AsyncCallback |
beforeProcess(Processor processor,
Exchange exchange,
AsyncCallback callback)
Strategy for optional work to be execute before processing For example the MDCUnitOfWork leverages this
to ensure MDC is handled correctly during routing exchanges using the
asynchronous routing engine. |
void |
beginSubUnitOfWork(Exchange exchange)
Begins a SubUnitOfWork , where sub (child) unit of works participate in a parent unit of work. |
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 |
endSubUnitOfWork(Exchange exchange)
Ends a SubUnitOfWork . |
void |
endTransactedBy(Object key)
Mark this UnitOfWork as not transacted anymore by the given transaction definition. |
String |
getId()
Returns the unique ID of this unit of work, lazily creating one if it does not yet have one |
Message |
getOriginalInMessage()
Gets the original IN Message this Unit of Work was started with. |
RouteContext |
getRouteContext()
Gets the RouteContext that this UnitOfWork currently is being routed through. |
SubUnitOfWorkCallback |
getSubUnitOfWorkCallback()
Gets the SubUnitOfWorkCallback if this unit of work participates in a sub unit of work. |
TracedRouteNodes |
getTracedRouteNodes()
Gets tracing information |
void |
handoverSynchronization(Exchange target)
/** Handover all the registered synchronizations to the target Exchange . |
boolean |
isTransacted()
Are we transacted? |
boolean |
isTransactedBy(Object key)
Are we already transacted by the given transaction key? |
RouteContext |
popRouteContext()
When finished being routed under the current RouteContext
it should be removed. |
void |
pushRouteContext(RouteContext routeContext)
Pushes the RouteContext that this UnitOfWork currently is being routed through. |
void |
removeSynchronization(Synchronization synchronization)
Removes a synchronization hook |
void |
setParentUnitOfWork(UnitOfWork parentUnitOfWork)
Sets the parent unit of work. |
Methods inherited from interface org.apache.camel.Service |
---|
start, stop |
Method Detail |
---|
void addSynchronization(Synchronization synchronization)
synchronization
- the hookvoid removeSynchronization(Synchronization synchronization)
synchronization
- the hookboolean containsSynchronization(Synchronization synchronization)
synchronization
- the hook
void 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 done(Exchange exchange)
exchange
- the current exchangeString getId()
Message getOriginalInMessage()
Message
this Unit of Work was started with.
Important: This is subject for change in a later Camel release, where we plan to only
support getting the original IN message if you have enabled this option explicit.
Message
, may return null in a later Camel release (see important note).TracedRouteNodes getTracedRouteNodes()
boolean isTransacted()
boolean isTransactedBy(Object key)
key
- the transaction key
void beginTransactedBy(Object key)
endTransactedBy(Object)
method using the same key.
key
- the transaction keyvoid endTransactedBy(Object key)
key
- the transaction keyRouteContext getRouteContext()
RouteContext
that this UnitOfWork
currently is being routed through.
Notice that an Exchange
can be routed through multiple routes and thus the
RouteContext
can change over time.
pushRouteContext(RouteContext)
,
popRouteContext()
void pushRouteContext(RouteContext routeContext)
RouteContext
that this UnitOfWork
currently is being routed through.
Notice that an Exchange
can be routed through multiple routes and thus the
RouteContext
can change over time.
routeContext
- the route contextRouteContext popRouteContext()
RouteContext
it should be removed.
AsyncCallback beforeProcess(Processor processor, Exchange exchange, AsyncCallback callback)
MDCUnitOfWork
leverages this
to ensure MDC is handled correctly during routing exchanges using the
asynchronous routing engine.
processor
- the processor to be executedexchange
- the current exchangecallback
- the callback
void afterProcess(Processor processor, Exchange exchange, AsyncCallback callback, boolean doneSync)
processor
- the processor executedexchange
- the current exchangecallback
- the callback useddoneSync
- whether the process was done synchronously or asynchronouslyUnitOfWork createChildUnitOfWork(Exchange childExchange)
SubUnitOfWork
s. For example a splitter,
where the sub messages of the splitter all participate in the same sub unit of work.
That sub unit of work then decides whether the Splitter (in general) is failed or a
processed successfully.
childExchange
- the child exchange
SubUnitOfWork
,
SubUnitOfWorkCallback
void setParentUnitOfWork(UnitOfWork parentUnitOfWork)
parentUnitOfWork
- the parentSubUnitOfWorkCallback getSubUnitOfWorkCallback()
SubUnitOfWorkCallback
if this unit of work participates in a sub unit of work.
beginSubUnitOfWork(org.apache.camel.Exchange)
void beginSubUnitOfWork(Exchange exchange)
SubUnitOfWork
, where sub (child) unit of works participate in a parent unit of work.
The SubUnitOfWork
will callback to the parent unit of work using SubUnitOfWorkCallback
s.
exchange
- the exchangevoid endSubUnitOfWork(Exchange exchange)
SubUnitOfWork
.
The beginSubUnitOfWork(org.apache.camel.Exchange)
must have been invoked
prior to this operation.
exchange
- the exchange
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |