Class JdbcOrphanLockAwareIdempotentRepository

  • All Implemented Interfaces:
    AutoCloseable, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.IdempotentRepository, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

    public class JdbcOrphanLockAwareIdempotentRepository
    extends JdbcMessageIdRepository
    implements org.apache.camel.ShutdownableService
    Implementation of AbstractJdbcMessageIdRepository which handles orphan locks resulting from jvm crash. When an instance of the application acquires a lock on the idempotent repository, the lock attributes are added to a HashSet. While the lock is help by the instance, the instance keeps updating the createdAt column with the current timestamp indicating the instance holding the lock is active. A lock is granted to an instance if either the entry for the lock attributes do not exists in the CAMEL_MESSAGEPROCESSED table or if in case the instance holding the lock has crashed. This is determined if the timestamp on the createdAt column is more than the lockMaxAge.
    • Constructor Detail

      • JdbcOrphanLockAwareIdempotentRepository

        public JdbcOrphanLockAwareIdempotentRepository​(org.apache.camel.CamelContext camelContext)
      • JdbcOrphanLockAwareIdempotentRepository

        public JdbcOrphanLockAwareIdempotentRepository​(DataSource dataSource,
                                                       String processorName,
                                                       org.apache.camel.CamelContext camelContext)
      • JdbcOrphanLockAwareIdempotentRepository

        public JdbcOrphanLockAwareIdempotentRepository​(DataSource dataSource,
                                                       org.springframework.transaction.support.TransactionTemplate transactionTemplate,
                                                       String processorName,
                                                       org.apache.camel.CamelContext camelContext)
      • JdbcOrphanLockAwareIdempotentRepository

        public JdbcOrphanLockAwareIdempotentRepository​(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
                                                       org.springframework.transaction.support.TransactionTemplate transactionTemplate,
                                                       org.apache.camel.CamelContext camelContext)
    • Method Detail

      • doShutdown

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

        public Set<org.apache.camel.processor.idempotent.jdbc.JdbcOrphanLockAwareIdempotentRepository.ProcessorNameAndMessageId> getProcessorNameMessageIdSet()
      • getUpdateTimestampQuery

        public String getUpdateTimestampQuery()
      • setUpdateTimestampQuery

        public void setUpdateTimestampQuery​(String updateTimestampQuery)
      • getLockMaxAgeMillis

        public long getLockMaxAgeMillis()
      • setLockMaxAgeMillis

        public void setLockMaxAgeMillis​(long lockMaxAgeMillis)
      • getLockKeepAliveIntervalMillis

        public long getLockKeepAliveIntervalMillis()
      • setLockKeepAliveIntervalMillis

        public void setLockKeepAliveIntervalMillis​(long lockKeepAliveIntervalMillis)