Class AbstractJdbcMessageIdRepository
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.processor.idempotent.jdbc.AbstractJdbcMessageIdRepository
- 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
- Direct Known Subclasses:
JdbcMessageIdRepository
@ManagedResource(description="JDBC IdempotentRepository")
public abstract class AbstractJdbcMessageIdRepository
extends org.apache.camel.support.service.ServiceSupport
implements org.apache.camel.spi.IdempotentRepository
Base class for JDBC-based idempotent repositories that allows the schema to be changed.
Subclasses need only implement theses methods:
These methods should perform the named database operation.
Important: Implementations of this should use String as the generic type as that is what is required
by Camel to allow using the idempotent repository with the Idempotent Consumer EIP and also as file consumer
read-lock. It was a mistake to make
IdempotentRepository parameterized, as it should have been a
pre-configured to use a String type.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DataSourceprotected org.springframework.jdbc.core.JdbcTemplateprotected org.slf4j.Loggerprotected Stringprotected org.springframework.transaction.support.TransactionTemplateFields 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
ConstructorsConstructorDescriptionAbstractJdbcMessageIdRepository(DataSource dataSource, String processorName) AbstractJdbcMessageIdRepository(DataSource dataSource, org.springframework.transaction.support.TransactionTemplate transactionTemplate, String processorName) AbstractJdbcMessageIdRepository(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, org.springframework.transaction.support.TransactionTemplate transactionTemplate) -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidclear()booleanbooleanprotected static org.springframework.transaction.support.TransactionTemplatecreateTransactionTemplate(DataSource dataSource) Creates the transaction templateprotected abstract intdelete()Operations that deletes all the rowsprotected abstract intOperations that deletes the key if it existsprotected voiddoStart()protected voiddoStop()org.springframework.jdbc.core.JdbcTemplateorg.springframework.transaction.support.TransactionTemplateprotected abstract intOperation that inserts the key if it does not already existprotected abstract intqueryForInt(String key) Operation that returns the number of rows, if any, for the specified keybooleanvoidsetDataSource(DataSource dataSource) voidsetJdbcTemplate(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate) voidsetProcessorName(String processorName) voidsetTransactionTemplate(org.springframework.transaction.support.TransactionTemplate transactionTemplate) Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.camel.spi.IdempotentRepository
add, confirm, contains, removeMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods 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
-
jdbcTemplate
protected org.springframework.jdbc.core.JdbcTemplate jdbcTemplate -
processorName
-
transactionTemplate
protected org.springframework.transaction.support.TransactionTemplate transactionTemplate -
dataSource
-
log
protected org.slf4j.Logger log
-
-
Constructor Details
-
AbstractJdbcMessageIdRepository
public AbstractJdbcMessageIdRepository() -
AbstractJdbcMessageIdRepository
public AbstractJdbcMessageIdRepository(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, org.springframework.transaction.support.TransactionTemplate transactionTemplate) -
AbstractJdbcMessageIdRepository
public AbstractJdbcMessageIdRepository(DataSource dataSource, org.springframework.transaction.support.TransactionTemplate transactionTemplate, String processorName) -
AbstractJdbcMessageIdRepository
-
-
Method Details
-
queryForInt
Operation that returns the number of rows, if any, for the specified key- Parameters:
key- the key- Returns:
- int number of rows
-
insert
Operation that inserts the key if it does not already exist- Parameters:
key- the key- Returns:
- int number of rows inserted
-
delete
Operations that deletes the key if it exists- Parameters:
key- the key- Returns:
- int number of rows deleted
-
delete
protected abstract int delete()Operations that deletes all the rows- Returns:
- int number of rows deleted
-
createTransactionTemplate
protected static org.springframework.transaction.support.TransactionTemplate createTransactionTemplate(DataSource dataSource) Creates the transaction template -
doStart
- Overrides:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doStop
- Overrides:
doStopin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
add
- Specified by:
addin interfaceorg.apache.camel.spi.IdempotentRepository
-
contains
@ManagedOperation(description="Does the store contain the given key") public boolean contains(String key) - Specified by:
containsin interfaceorg.apache.camel.spi.IdempotentRepository
-
remove
- Specified by:
removein interfaceorg.apache.camel.spi.IdempotentRepository
-
clear
@ManagedOperation(description="Clear the store") public void clear()- Specified by:
clearin interfaceorg.apache.camel.spi.IdempotentRepository
-
confirm
- Specified by:
confirmin interfaceorg.apache.camel.spi.IdempotentRepository
-
getJdbcTemplate
public org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate() -
setJdbcTemplate
public void setJdbcTemplate(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate) -
getProcessorName
-
setProcessorName
-
getTransactionTemplate
public org.springframework.transaction.support.TransactionTemplate getTransactionTemplate() -
setTransactionTemplate
public void setTransactionTemplate(org.springframework.transaction.support.TransactionTemplate transactionTemplate) -
getDataSource
-
setDataSource
-