public class JdbcAggregationRepository
extends org.apache.camel.support.ServiceSupport
implements org.apache.camel.spi.RecoverableAggregationRepository, org.apache.camel.spi.OptimisticLockingAggregationRepository
AggregationRepository
JdbcAggregationRepository will only preserve any Serializable compatible
data types. If a data type is not such a type its dropped and a WARN is
logged. And it only persists the Message body and the Message headers.
The Exchange properties are not persisted.| Constructor and Description |
|---|
JdbcAggregationRepository()
Creates an aggregation repository
|
JdbcAggregationRepository(org.springframework.transaction.PlatformTransactionManager transactionManager,
String repositoryName,
DataSource dataSource)
Creates an aggregation repository with the three mandatory parameters
|
| Modifier and Type | Method and Description |
|---|---|
org.apache.camel.Exchange |
add(org.apache.camel.CamelContext camelContext,
String correlationId,
org.apache.camel.Exchange exchange) |
org.apache.camel.Exchange |
add(org.apache.camel.CamelContext camelContext,
String correlationId,
org.apache.camel.Exchange oldExchange,
org.apache.camel.Exchange newExchange) |
void |
confirm(org.apache.camel.CamelContext camelContext,
String exchangeId) |
protected void |
doStart() |
protected void |
doStop() |
org.apache.camel.Exchange |
get(org.apache.camel.CamelContext camelContext,
String correlationId) |
String |
getDeadLetterUri() |
JdbcOptimisticLockingExceptionMapper |
getJdbcOptimisticLockingExceptionMapper() |
Set<String> |
getKeys() |
protected Set<String> |
getKeys(String repositoryName)
Returns the keys in the given repository
|
org.springframework.jdbc.support.lob.LobHandler |
getLobHandler() |
int |
getMaximumRedeliveries() |
long |
getRecoveryIntervalInMillis() |
String |
getRepositoryName() |
String |
getRepositoryNameCompleted() |
boolean |
hasHeadersToStoreAsText() |
protected void |
insert(org.apache.camel.CamelContext camelContext,
String correlationId,
org.apache.camel.Exchange exchange,
String repositoryName)
Inserts a new record into the given repository table.
|
protected void |
insertAndUpdateHelper(org.apache.camel.CamelContext camelContext,
String key,
org.apache.camel.Exchange exchange,
String sql,
boolean idComesFirst) |
boolean |
isAllowSerializedHeaders() |
boolean |
isReturnOldExchange() |
boolean |
isUseRecovery() |
org.apache.camel.Exchange |
recover(org.apache.camel.CamelContext camelContext,
String exchangeId) |
void |
remove(org.apache.camel.CamelContext camelContext,
String correlationId,
org.apache.camel.Exchange exchange) |
Set<String> |
scan(org.apache.camel.CamelContext camelContext) |
void |
setAllowSerializedHeaders(boolean allowSerializedHeaders) |
void |
setDataSource(DataSource dataSource) |
void |
setDeadLetterUri(String deadLetterUri) |
void |
setHeadersToStoreAsText(List<String> headersToStoreAsText)
Allows to store headers as String which is human readable.
|
void |
setJdbcCamelCodec(JdbcCamelCodec codec) |
void |
setJdbcOptimisticLockingExceptionMapper(JdbcOptimisticLockingExceptionMapper jdbcOptimisticLockingExceptionMapper) |
void |
setLobHandler(org.springframework.jdbc.support.lob.LobHandler lobHandler) |
void |
setMaximumRedeliveries(int maximumRedeliveries) |
void |
setRecoveryInterval(long interval) |
void |
setRecoveryInterval(long interval,
TimeUnit timeUnit)
If recovery is enabled then a background task is run every x'th time to scan for failed exchanges to recover
and resubmit.
|
void |
setRepositoryName(String repositoryName) |
void |
setReturnOldExchange(boolean returnOldExchange) |
void |
setStoreBodyAsText(boolean storeBodyAsText) |
void |
setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager) |
void |
setUseRecovery(boolean useRecovery) |
protected void |
update(org.apache.camel.CamelContext camelContext,
String key,
org.apache.camel.Exchange exchange,
String repositoryName)
Updates the current exchange details in the given repository table
|
public JdbcAggregationRepository()
public JdbcAggregationRepository(org.springframework.transaction.PlatformTransactionManager transactionManager,
String repositoryName,
DataSource dataSource)
public final void setRepositoryName(String repositoryName)
repositoryName - the repositoryName to setpublic final void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
public final void setDataSource(DataSource dataSource)
dataSource - The DataSource to use for accessing the databasepublic org.apache.camel.Exchange add(org.apache.camel.CamelContext camelContext,
String correlationId,
org.apache.camel.Exchange oldExchange,
org.apache.camel.Exchange newExchange)
throws org.apache.camel.spi.OptimisticLockingAggregationRepository.OptimisticLockingException
add in interface org.apache.camel.spi.OptimisticLockingAggregationRepositoryorg.apache.camel.spi.OptimisticLockingAggregationRepository.OptimisticLockingExceptionpublic org.apache.camel.Exchange add(org.apache.camel.CamelContext camelContext,
String correlationId,
org.apache.camel.Exchange exchange)
add in interface org.apache.camel.spi.AggregationRepositoryprotected void update(org.apache.camel.CamelContext camelContext,
String key,
org.apache.camel.Exchange exchange,
String repositoryName)
throws Exception
camelContext - the current CamelContextkey - the correlation keyexchange - the aggregated exchangerepositoryName - The name of the tableExceptionprotected void insert(org.apache.camel.CamelContext camelContext,
String correlationId,
org.apache.camel.Exchange exchange,
String repositoryName)
throws Exception
camelContext - the current CamelContextcorrelationId - the correlation keyexchange - the aggregated exchange to insert. The headers will be persisted but not the properties.repositoryName - The name of the tableExceptionprotected void insertAndUpdateHelper(org.apache.camel.CamelContext camelContext,
String key,
org.apache.camel.Exchange exchange,
String sql,
boolean idComesFirst)
throws Exception
Exceptionpublic org.apache.camel.Exchange get(org.apache.camel.CamelContext camelContext,
String correlationId)
get in interface org.apache.camel.spi.AggregationRepositorypublic void remove(org.apache.camel.CamelContext camelContext,
String correlationId,
org.apache.camel.Exchange exchange)
remove in interface org.apache.camel.spi.AggregationRepositoryremove in interface org.apache.camel.spi.OptimisticLockingAggregationRepositorypublic void confirm(org.apache.camel.CamelContext camelContext,
String exchangeId)
confirm in interface org.apache.camel.spi.AggregationRepositorypublic Set<String> getKeys()
getKeys in interface org.apache.camel.spi.AggregationRepositorypublic Set<String> scan(org.apache.camel.CamelContext camelContext)
scan in interface org.apache.camel.spi.RecoverableAggregationRepositoryprotected Set<String> getKeys(String repositoryName)
repositoryName - The name of the tablepublic org.apache.camel.Exchange recover(org.apache.camel.CamelContext camelContext,
String exchangeId)
recover in interface org.apache.camel.spi.RecoverableAggregationRepositorypublic void setRecoveryInterval(long interval,
TimeUnit timeUnit)
setRecoveryInterval in interface org.apache.camel.spi.RecoverableAggregationRepositoryinterval - the intervaltimeUnit - the time unitpublic void setRecoveryInterval(long interval)
setRecoveryInterval in interface org.apache.camel.spi.RecoverableAggregationRepositorypublic long getRecoveryIntervalInMillis()
getRecoveryIntervalInMillis in interface org.apache.camel.spi.RecoverableAggregationRepositorypublic boolean isUseRecovery()
isUseRecovery in interface org.apache.camel.spi.RecoverableAggregationRepositorypublic void setUseRecovery(boolean useRecovery)
setUseRecovery in interface org.apache.camel.spi.RecoverableAggregationRepositoryuseRecovery - Whether or not recovery is enabled. This option is by default true. When enabled the Camel
Aggregator automatic recover failed aggregated exchange and have them resubmitteddpublic int getMaximumRedeliveries()
getMaximumRedeliveries in interface org.apache.camel.spi.RecoverableAggregationRepositorypublic void setMaximumRedeliveries(int maximumRedeliveries)
setMaximumRedeliveries in interface org.apache.camel.spi.RecoverableAggregationRepositorypublic String getDeadLetterUri()
getDeadLetterUri in interface org.apache.camel.spi.RecoverableAggregationRepositorypublic void setDeadLetterUri(String deadLetterUri)
setDeadLetterUri in interface org.apache.camel.spi.RecoverableAggregationRepositorydeadLetterUri - An endpoint uri for a Dead Letter Channel where exhausted recovered Exchanges will be
moved. If this option is used then the maximumRedeliveries option must also be provided.
Important note : if the deadletter route throws an exception, it will be send again to DLQ
until it succeed !public boolean isReturnOldExchange()
public void setReturnOldExchange(boolean returnOldExchange)
returnOldExchange - Whether the get operation should return the old existing Exchange if any existed.
By default this option is false to optimize as we do not need the old exchange when
aggregatingpublic void setJdbcCamelCodec(JdbcCamelCodec codec)
public boolean hasHeadersToStoreAsText()
public void setHeadersToStoreAsText(List<String> headersToStoreAsText)
headersToStoreAsText - the list of headers to store as Stringpublic void setStoreBodyAsText(boolean storeBodyAsText)
storeBodyAsText - Whether to store the message body as String which is human readable.
By default this option is false storing the body in binary format.public boolean isAllowSerializedHeaders()
public void setAllowSerializedHeaders(boolean allowSerializedHeaders)
public org.springframework.jdbc.support.lob.LobHandler getLobHandler()
public void setLobHandler(org.springframework.jdbc.support.lob.LobHandler lobHandler)
lobHandler - the lobHandler to setpublic JdbcOptimisticLockingExceptionMapper getJdbcOptimisticLockingExceptionMapper()
public void setJdbcOptimisticLockingExceptionMapper(JdbcOptimisticLockingExceptionMapper jdbcOptimisticLockingExceptionMapper)
public String getRepositoryName()
public String getRepositoryNameCompleted()
protected void doStart()
throws Exception
doStart in class org.apache.camel.support.ServiceSupportExceptionApache Camel