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.Modifier and Type | Field and Description |
---|---|
protected static String |
BODY |
protected static String |
EXCHANGE |
protected static String |
ID |
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() |
List<String> |
getHeadersToStoreAsText() |
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() |
int |
getPropagationBehavior() |
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 int |
insertAndUpdateHelper(org.apache.camel.CamelContext camelContext,
String key,
org.apache.camel.Exchange exchange,
String sql,
boolean idComesFirst) |
boolean |
isAllowSerializedHeaders() |
boolean |
isReturnOldExchange() |
boolean |
isStoreBodyAsText() |
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)
Sets a custom LobHandler to use
|
void |
setMaximumRedeliveries(int maximumRedeliveries) |
void |
setPropagationBehavior(int propagationBehavior)
Sets propagation behavior to use with spring transaction templates which are used for database access.
|
void |
setPropagationBehaviorName(String propagationBehaviorName)
Sets propagation behavior to use with spring transaction templates which are used for database access.
|
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)
Sets the name of the repository
|
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
|
protected static final String EXCHANGE
protected static final String ID
protected static final String BODY
public JdbcAggregationRepository()
public JdbcAggregationRepository(org.springframework.transaction.PlatformTransactionManager transactionManager, String repositoryName, DataSource dataSource)
public final void setRepositoryName(String repositoryName)
public final void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
public 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.OptimisticLockingAggregationRepository
org.apache.camel.spi.OptimisticLockingAggregationRepository.OptimisticLockingException
public org.apache.camel.Exchange add(org.apache.camel.CamelContext camelContext, String correlationId, org.apache.camel.Exchange exchange)
add
in interface org.apache.camel.spi.AggregationRepository
protected 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 tableException
protected 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 tableException
protected int insertAndUpdateHelper(org.apache.camel.CamelContext camelContext, String key, org.apache.camel.Exchange exchange, String sql, boolean idComesFirst) throws Exception
Exception
public org.apache.camel.Exchange get(org.apache.camel.CamelContext camelContext, String correlationId)
get
in interface org.apache.camel.spi.AggregationRepository
public void remove(org.apache.camel.CamelContext camelContext, String correlationId, org.apache.camel.Exchange exchange)
remove
in interface org.apache.camel.spi.AggregationRepository
remove
in interface org.apache.camel.spi.OptimisticLockingAggregationRepository
public void confirm(org.apache.camel.CamelContext camelContext, String exchangeId)
confirm
in interface org.apache.camel.spi.AggregationRepository
public Set<String> getKeys()
getKeys
in interface org.apache.camel.spi.AggregationRepository
public Set<String> scan(org.apache.camel.CamelContext camelContext)
scan
in interface org.apache.camel.spi.RecoverableAggregationRepository
protected 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.RecoverableAggregationRepository
public void setRecoveryInterval(long interval, TimeUnit timeUnit)
setRecoveryInterval
in interface org.apache.camel.spi.RecoverableAggregationRepository
interval
- the intervaltimeUnit
- the time unitpublic void setRecoveryInterval(long interval)
setRecoveryInterval
in interface org.apache.camel.spi.RecoverableAggregationRepository
public long getRecoveryIntervalInMillis()
getRecoveryIntervalInMillis
in interface org.apache.camel.spi.RecoverableAggregationRepository
public boolean isUseRecovery()
isUseRecovery
in interface org.apache.camel.spi.RecoverableAggregationRepository
public void setUseRecovery(boolean useRecovery)
setUseRecovery
in interface org.apache.camel.spi.RecoverableAggregationRepository
useRecovery
- 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.RecoverableAggregationRepository
public void setMaximumRedeliveries(int maximumRedeliveries)
setMaximumRedeliveries
in interface org.apache.camel.spi.RecoverableAggregationRepository
public String getDeadLetterUri()
getDeadLetterUri
in interface org.apache.camel.spi.RecoverableAggregationRepository
public void setDeadLetterUri(String deadLetterUri)
setDeadLetterUri
in interface org.apache.camel.spi.RecoverableAggregationRepository
deadLetterUri
- 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 boolean isStoreBodyAsText()
public 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 int getPropagationBehavior()
public void setPropagationBehavior(int propagationBehavior)
public void setPropagationBehaviorName(String propagationBehaviorName)
propagationBehaviorName
- public org.springframework.jdbc.support.lob.LobHandler getLobHandler()
public void setLobHandler(org.springframework.jdbc.support.lob.LobHandler lobHandler)
public 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.ServiceSupport
Exception
Apache Camel