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 final org.apache.camel.CamelContext
     
    protected final org.apache.camel.Processor
     
    protected boolean
     

    Fields inherited from class org.apache.camel.processor.errorhandler.ErrorHandlerSupport

    DEFAULT_EXCHANGE_FORMATTER, exceptionPolicies, exceptionPolicy

    Fields inherited from class org.apache.camel.support.ChildServiceSupport

    childServices

    Fields 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

    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

    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
     
    protected void
     
    protected void
     
    org.apache.camel.Processor
     
    boolean
     
    List<org.apache.camel.Processor>
     
    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 the Exchange using the error handler.
    protected void
    processInTransaction(org.apache.camel.Exchange exchange)
     
    void
     
    boolean
     

    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

    Methods inherited from interface org.apache.camel.Service

    build, close, init

    Methods inherited from interface org.apache.camel.StatefulService

    getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending

    Methods 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 context
      output - outer processor that should use this default error handler
      transactionPolicy - the transaction policy
      rollbackLoggingLevel - 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:
      clone in class org.apache.camel.processor.errorhandler.ErrorHandlerSupport
    • process

      public void process(org.apache.camel.Exchange exchange) throws Exception
      Specified by:
      process in interface org.apache.camel.Processor
      Throws:
      Exception
    • process

      public boolean process(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback)
      Specified by:
      process in interface org.apache.camel.AsyncProcessor
    • processAsync

      public CompletableFuture<org.apache.camel.Exchange> processAsync(org.apache.camel.Exchange exchange)
      Specified by:
      processAsync in interface org.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 the Exchange 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 class org.apache.camel.processor.errorhandler.ErrorHandlerSupport
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doShutdown

      protected void doShutdown() throws Exception
      Overrides:
      doShutdown in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • supportTransacted

      public boolean supportTransacted()
      Specified by:
      supportTransacted in class org.apache.camel.processor.errorhandler.ErrorHandlerSupport
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface org.apache.camel.Navigate<org.apache.camel.Processor>
    • next

      public List<org.apache.camel.Processor> next()
      Specified by:
      next in interface org.apache.camel.Navigate<org.apache.camel.Processor>
    • prepareShutdown

      public void prepareShutdown(boolean suspendOnly, boolean forced)
      Specified by:
      prepareShutdown in interface org.apache.camel.spi.ShutdownPrepared