|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.camel.impl.DefaultUnitOfWork
public class DefaultUnitOfWork
The default implementation of UnitOfWork
Constructor Summary | |
---|---|
|
DefaultUnitOfWork(Exchange exchange)
|
protected |
DefaultUnitOfWork(Exchange exchange,
org.slf4j.Logger logger)
|
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. |
void |
start()
Starts the service |
void |
stop()
Stops the service |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DefaultUnitOfWork(Exchange exchange)
protected DefaultUnitOfWork(Exchange exchange, org.slf4j.Logger logger)
Method Detail |
---|
public void setParentUnitOfWork(UnitOfWork parentUnitOfWork)
UnitOfWork
setParentUnitOfWork
in interface UnitOfWork
parentUnitOfWork
- the parentpublic UnitOfWork createChildUnitOfWork(Exchange childExchange)
UnitOfWork
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.
createChildUnitOfWork
in interface UnitOfWork
childExchange
- the child exchange
SubUnitOfWork
,
SubUnitOfWorkCallback
public void start() throws Exception
Service
start
in interface Service
Exception
- is thrown if starting failedpublic void stop() throws Exception
Service
stop
in interface Service
Exception
- is thrown if stopping failedpublic void addSynchronization(Synchronization synchronization)
UnitOfWork
addSynchronization
in interface UnitOfWork
synchronization
- the hookpublic void removeSynchronization(Synchronization synchronization)
UnitOfWork
removeSynchronization
in interface UnitOfWork
synchronization
- the hookpublic boolean containsSynchronization(Synchronization synchronization)
UnitOfWork
containsSynchronization
in interface UnitOfWork
synchronization
- the hook
public void handoverSynchronization(Exchange target)
UnitOfWork
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.
handoverSynchronization
in interface UnitOfWork
target
- the target exchangepublic void done(Exchange exchange)
UnitOfWork
done
in interface UnitOfWork
exchange
- the current exchangepublic String getId()
UnitOfWork
getId
in interface UnitOfWork
public Message getOriginalInMessage()
UnitOfWork
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.
getOriginalInMessage
in interface UnitOfWork
Message
, may return null in a later Camel release (see important note).public TracedRouteNodes getTracedRouteNodes()
UnitOfWork
getTracedRouteNodes
in interface UnitOfWork
public boolean isTransacted()
UnitOfWork
isTransacted
in interface UnitOfWork
public boolean isTransactedBy(Object key)
UnitOfWork
isTransactedBy
in interface UnitOfWork
key
- the transaction key
public void beginTransactedBy(Object key)
UnitOfWork
UnitOfWork.endTransactedBy(Object)
method using the same key.
beginTransactedBy
in interface UnitOfWork
key
- the transaction keypublic void endTransactedBy(Object key)
UnitOfWork
endTransactedBy
in interface UnitOfWork
key
- the transaction keypublic RouteContext getRouteContext()
UnitOfWork
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.
getRouteContext
in interface UnitOfWork
UnitOfWork.pushRouteContext(RouteContext)
,
UnitOfWork.popRouteContext()
public void pushRouteContext(RouteContext routeContext)
UnitOfWork
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
in interface UnitOfWork
routeContext
- the route contextpublic RouteContext popRouteContext()
UnitOfWork
RouteContext
it should be removed.
popRouteContext
in interface UnitOfWork
public AsyncCallback beforeProcess(Processor processor, Exchange exchange, AsyncCallback callback)
UnitOfWork
MDCUnitOfWork
leverages this
to ensure MDC is handled correctly during routing exchanges using the
asynchronous routing engine.
beforeProcess
in interface UnitOfWork
processor
- the processor to be executedexchange
- the current exchangecallback
- the callback
public void afterProcess(Processor processor, Exchange exchange, AsyncCallback callback, boolean doneSync)
UnitOfWork
afterProcess
in interface UnitOfWork
processor
- the processor executedexchange
- the current exchangecallback
- the callback useddoneSync
- whether the process was done synchronously or asynchronouslypublic void beginSubUnitOfWork(Exchange exchange)
UnitOfWork
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.
beginSubUnitOfWork
in interface UnitOfWork
exchange
- the exchangepublic void endSubUnitOfWork(Exchange exchange)
UnitOfWork
SubUnitOfWork
.
The UnitOfWork.beginSubUnitOfWork(org.apache.camel.Exchange)
must have been invoked
prior to this operation.
endSubUnitOfWork
in interface UnitOfWork
exchange
- the exchangepublic SubUnitOfWorkCallback getSubUnitOfWorkCallback()
UnitOfWork
SubUnitOfWorkCallback
if this unit of work participates in a sub unit of work.
getSubUnitOfWorkCallback
in interface UnitOfWork
UnitOfWork.beginSubUnitOfWork(org.apache.camel.Exchange)
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |