Package org.apache.camel.jta
Class TransactionErrorHandler
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.ChildServiceSupport
-
- org.apache.camel.processor.errorhandler.ErrorHandlerSupport
-
- org.apache.camel.jta.TransactionErrorHandler
-
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.AsyncProcessor
,org.apache.camel.Navigate<org.apache.camel.Processor>
,org.apache.camel.Processor
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.ErrorHandler
,org.apache.camel.spi.ShutdownPrepared
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
public class TransactionErrorHandler extends org.apache.camel.processor.errorhandler.ErrorHandlerSupport implements org.apache.camel.AsyncProcessor, org.apache.camel.spi.ShutdownPrepared, org.apache.camel.Navigate<org.apache.camel.Processor>
Does transactional execution according given policy. This class is based on org.apache.camel.spring.spi.TransactionErrorHandler excluding redelivery functionality. In the Spring implementation redelivering is done within the transaction which is not appropriate in JTA since every error breaks the current transaction.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.camel.CamelContext
camelContext
protected org.apache.camel.Processor
output
protected boolean
preparingShutdown
-
Constructor Summary
Constructors Constructor Description TransactionErrorHandler(org.apache.camel.CamelContext camelContext, org.apache.camel.Processor output, JtaTransactionPolicy transactionPolicy, org.apache.camel.LoggingLevel rollbackLoggingLevel)
Creates the transaction error handler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.camel.spi.ErrorHandler
clone(org.apache.camel.Processor output)
protected void
doInTransactionTemplate(org.apache.camel.Exchange exchange)
protected void
doShutdown()
protected void
doStart()
protected void
doStop()
org.apache.camel.Processor
getOutput()
boolean
hasNext()
List<org.apache.camel.Processor>
next()
void
prepareShutdown(boolean suspendOnly, boolean forced)
void
process(org.apache.camel.Exchange exchange)
boolean
process(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback)
CompletableFuture<org.apache.camel.Exchange>
processAsync(org.apache.camel.Exchange exchange)
protected void
processByErrorHandler(org.apache.camel.Exchange exchange)
Processes theExchange
using the error handler.protected void
processInTransaction(org.apache.camel.Exchange exchange)
void
setTransactionPolicy(JtaTransactionPolicy transactionPolicy)
boolean
supportTransacted()
-
Methods inherited from class org.apache.camel.processor.errorhandler.ErrorHandlerSupport
addErrorHandler, addExceptionPolicy, getExceptionPolicy, isDeadLetterChannel
-
Methods inherited from class org.apache.camel.support.ChildServiceSupport
addChildService, removeChildService, shutdown, start, stop
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, suspend
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Constructor Detail
-
TransactionErrorHandler
public TransactionErrorHandler(org.apache.camel.CamelContext camelContext, org.apache.camel.Processor output, JtaTransactionPolicy transactionPolicy, org.apache.camel.LoggingLevel rollbackLoggingLevel)
Creates the transaction error handler.- Parameters:
camelContext
- the camel contextoutput
- outer processor that should use this default error handlertransactionPolicy
- the transaction policyrollbackLoggingLevel
- logging level to use for logging transaction rollback occurred
-
-
Method Detail
-
clone
public org.apache.camel.spi.ErrorHandler clone(org.apache.camel.Processor output)
- Specified by:
clone
in classorg.apache.camel.processor.errorhandler.ErrorHandlerSupport
-
process
public void process(org.apache.camel.Exchange exchange) throws Exception
- Specified by:
process
in interfaceorg.apache.camel.Processor
- Throws:
Exception
-
process
public boolean process(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback)
- Specified by:
process
in interfaceorg.apache.camel.AsyncProcessor
-
processAsync
public CompletableFuture<org.apache.camel.Exchange> processAsync(org.apache.camel.Exchange exchange)
- Specified by:
processAsync
in interfaceorg.apache.camel.AsyncProcessor
-
processInTransaction
protected void processInTransaction(org.apache.camel.Exchange exchange)
-
setTransactionPolicy
public void setTransactionPolicy(JtaTransactionPolicy transactionPolicy)
-
doInTransactionTemplate
protected void doInTransactionTemplate(org.apache.camel.Exchange exchange) throws Throwable
- Throws:
Throwable
-
processByErrorHandler
protected void processByErrorHandler(org.apache.camel.Exchange exchange)
Processes theExchange
using the error handler. This implementation will invoke ensure this occurs synchronously, that means if the async routing engine did kick in, then this implementation will wait for the task to complete before it continues.- Parameters:
exchange
- the exchange
-
getOutput
public org.apache.camel.Processor getOutput()
- Specified by:
getOutput
in classorg.apache.camel.processor.errorhandler.ErrorHandlerSupport
-
doStart
protected void doStart() throws Exception
- Overrides:
doStart
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doStop
protected void doStop() throws Exception
- Overrides:
doStop
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doShutdown
protected void doShutdown() throws Exception
- Overrides:
doShutdown
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
supportTransacted
public boolean supportTransacted()
- Specified by:
supportTransacted
in classorg.apache.camel.processor.errorhandler.ErrorHandlerSupport
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfaceorg.apache.camel.Navigate<org.apache.camel.Processor>
-
next
public List<org.apache.camel.Processor> next()
- Specified by:
next
in interfaceorg.apache.camel.Navigate<org.apache.camel.Processor>
-
prepareShutdown
public void prepareShutdown(boolean suspendOnly, boolean forced)
- Specified by:
prepareShutdown
in interfaceorg.apache.camel.spi.ShutdownPrepared
-
-