public class JdbcOrphanLockAwareIdempotentRepository extends JdbcMessageIdRepository implements org.apache.camel.ShutdownableService
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.DEFAULT_TABLENAMEdataSource, jdbcTemplate, log, processorName, transactionTemplate| Constructor and Description |
|---|
JdbcOrphanLockAwareIdempotentRepository(org.apache.camel.CamelContext camelContext) |
JdbcOrphanLockAwareIdempotentRepository(DataSource dataSource,
String processorName,
org.apache.camel.CamelContext camelContext) |
JdbcOrphanLockAwareIdempotentRepository(DataSource dataSource,
org.springframework.transaction.support.TransactionTemplate transactionTemplate,
String processorName,
org.apache.camel.CamelContext camelContext) |
JdbcOrphanLockAwareIdempotentRepository(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
org.springframework.transaction.support.TransactionTemplate transactionTemplate,
org.apache.camel.CamelContext camelContext) |
| Modifier and Type | Method and Description |
|---|---|
protected int |
delete()
Operations that deletes all the rows
|
protected int |
delete(String key)
Operations that deletes the key if it exists
|
protected void |
doInit() |
protected void |
doShutdown() |
long |
getLockKeepAliveIntervalMillis() |
long |
getLockMaxAgeMillis() |
Set<org.apache.camel.processor.idempotent.jdbc.JdbcOrphanLockAwareIdempotentRepository.ProcessorNameAndMessageId> |
getProcessorNameMessageIdSet() |
String |
getUpdateTimestampQuery() |
protected int |
insert(String key)
Operation that inserts the key if it does not already exist
|
protected int |
queryForInt(String key)
Operation that returns the number of rows, if any, for the specified key
|
void |
setLockKeepAliveIntervalMillis(long lockKeepAliveIntervalMillis) |
void |
setLockMaxAgeMillis(long lockMaxAgeMillis) |
void |
setUpdateTimestampQuery(String updateTimestampQuery) |
doStart, getClearString, getCreateString, getDeleteString, getInsertString, getQueryString, getTableExistsString, getTableName, isCreateTableIfNotExists, setClearString, setCreateString, setCreateTableIfNotExists, setDeleteString, setInsertString, setQueryString, setTableExistsString, setTableNameadd, clear, confirm, contains, createTransactionTemplate, doStop, getDataSource, getJdbcTemplate, getProcessorName, getTransactionTemplate, remove, setDataSource, setJdbcTemplate, setProcessorName, setTransactionTemplatebuild, doBuild, doFail, doLifecycleChange, doResume, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitadd, confirm, contains, removepublic JdbcOrphanLockAwareIdempotentRepository(org.apache.camel.CamelContext camelContext)
public JdbcOrphanLockAwareIdempotentRepository(DataSource dataSource, String processorName, org.apache.camel.CamelContext camelContext)
public JdbcOrphanLockAwareIdempotentRepository(DataSource dataSource, org.springframework.transaction.support.TransactionTemplate transactionTemplate, String processorName, org.apache.camel.CamelContext camelContext)
public JdbcOrphanLockAwareIdempotentRepository(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
org.springframework.transaction.support.TransactionTemplate transactionTemplate,
org.apache.camel.CamelContext camelContext)
protected int queryForInt(String key)
AbstractJdbcMessageIdRepositoryqueryForInt in class JdbcMessageIdRepositorykey - the keyprotected int delete(String key)
AbstractJdbcMessageIdRepositorydelete in class JdbcMessageIdRepositorykey - the keyprotected int insert(String key)
AbstractJdbcMessageIdRepositoryinsert in class JdbcMessageIdRepositorykey - the keyprotected void doInit()
throws Exception
doInit in class JdbcMessageIdRepositoryExceptionprotected void doShutdown()
throws Exception
doShutdown in class org.apache.camel.support.service.BaseServiceExceptionprotected int delete()
AbstractJdbcMessageIdRepositorydelete in class JdbcMessageIdRepositorypublic Set<org.apache.camel.processor.idempotent.jdbc.JdbcOrphanLockAwareIdempotentRepository.ProcessorNameAndMessageId> getProcessorNameMessageIdSet()
public String getUpdateTimestampQuery()
public void setUpdateTimestampQuery(String updateTimestampQuery)
public long getLockMaxAgeMillis()
public void setLockMaxAgeMillis(long lockMaxAgeMillis)
public long getLockKeepAliveIntervalMillis()
public void setLockKeepAliveIntervalMillis(long lockKeepAliveIntervalMillis)
Apache Camel