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
FieldsModifier and TypeFieldDescriptionprotected final org.apache.camel.CamelContextprotected final org.apache.camel.Processorprotected booleanFields inherited from class org.apache.camel.processor.errorhandler.ErrorHandlerSupport
DEFAULT_EXCHANGE_FORMATTER, exceptionPolicies, exceptionPolicyFields inherited from class org.apache.camel.support.ChildServiceSupport
childServicesFields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING -
Constructor Summary
ConstructorsConstructorDescriptionTransactionErrorHandler(org.apache.camel.CamelContext camelContext, org.apache.camel.Processor output, JtaTransactionPolicy transactionPolicy, org.apache.camel.LoggingLevel rollbackLoggingLevel) Creates the transaction error handler. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.camel.spi.ErrorHandlerclone(org.apache.camel.Processor output) protected voiddoInTransactionTemplate(org.apache.camel.Exchange exchange) protected voidprotected voiddoStart()protected voiddoStop()org.apache.camel.ProcessorbooleanhasNext()List<org.apache.camel.Processor>next()voidprepareShutdown(boolean suspendOnly, boolean forced) voidprocess(org.apache.camel.Exchange exchange) booleanprocess(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback) CompletableFuture<org.apache.camel.Exchange>processAsync(org.apache.camel.Exchange exchange) protected voidprocessByErrorHandler(org.apache.camel.Exchange exchange) Processes theExchangeusing the error handler.protected voidprocessInTransaction(org.apache.camel.Exchange exchange) voidsetTransactionPolicy(JtaTransactionPolicy transactionPolicy) booleanMethods inherited from class org.apache.camel.processor.errorhandler.ErrorHandlerSupport
addErrorHandler, addExceptionPolicy, getExceptionPolicy, isDeadLetterChannelMethods inherited from class org.apache.camel.support.ChildServiceSupport
addChildService, removeChildService, shutdown, start, stopMethods 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, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.camel.Service
build, close, initMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Field Details
-
camelContext
protected final org.apache.camel.CamelContext camelContext -
output
protected final org.apache.camel.Processor output -
preparingShutdown
protected volatile boolean preparingShutdown
-
-
Constructor Details
-
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 Details
-
clone
public org.apache.camel.spi.ErrorHandler clone(org.apache.camel.Processor output) - Specified by:
clonein classorg.apache.camel.processor.errorhandler.ErrorHandlerSupport
-
process
- Specified by:
processin interfaceorg.apache.camel.Processor- Throws:
Exception
-
process
public boolean process(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback) - Specified by:
processin interfaceorg.apache.camel.AsyncProcessor
-
processAsync
public CompletableFuture<org.apache.camel.Exchange> processAsync(org.apache.camel.Exchange exchange) - Specified by:
processAsyncin interfaceorg.apache.camel.AsyncProcessor
-
processInTransaction
protected void processInTransaction(org.apache.camel.Exchange exchange) -
setTransactionPolicy
-
doInTransactionTemplate
- Throws:
Throwable
-
processByErrorHandler
protected void processByErrorHandler(org.apache.camel.Exchange exchange) Processes theExchangeusing 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:
getOutputin classorg.apache.camel.processor.errorhandler.ErrorHandlerSupport
-
doStart
- Overrides:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doStop
- Overrides:
doStopin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doShutdown
- Overrides:
doShutdownin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
supportTransacted
public boolean supportTransacted()- Specified by:
supportTransactedin classorg.apache.camel.processor.errorhandler.ErrorHandlerSupport
-
hasNext
public boolean hasNext()- Specified by:
hasNextin interfaceorg.apache.camel.Navigate<org.apache.camel.Processor>
-
next
- Specified by:
nextin interfaceorg.apache.camel.Navigate<org.apache.camel.Processor>
-
prepareShutdown
public void prepareShutdown(boolean suspendOnly, boolean forced) - Specified by:
prepareShutdownin interfaceorg.apache.camel.spi.ShutdownPrepared
-