Package org.apache.camel.spi
Interface OptimisticLockingAggregationRepository
- All Superinterfaces:
AggregationRepository
A specialized
AggregationRepository which also supports optimistic locking.
If the underlying implementation cannot perform optimistic locking, it should not implement this interface.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classExceptionused by anAggregationRepositoryto indicate that an optimistic update error has occurred and that the operation should be retried by the caller. -
Method Summary
Modifier and TypeMethodDescriptionadd(CamelContext camelContext, String key, Exchange oldExchange, Exchange newExchange) Add the givenExchangeunder the correlation key.voidremove(CamelContext camelContext, String key, Exchange exchange) Removes the given Exchange when both the supplied key and Exchange are present in the repository.Methods inherited from interface org.apache.camel.spi.AggregationRepository
add, confirm, get, getKeys
-
Method Details
-
add
Exchange add(CamelContext camelContext, String key, Exchange oldExchange, Exchange newExchange) throws OptimisticLockingAggregationRepository.OptimisticLockingException Add the givenExchangeunder the correlation key. Will perform optimistic locking to replace expected existing exchange with the new supplied exchange. If theoldExchangeis null the underlying implementation is to assume this is the very first Exchange for the supplied correlation key. When the implementation comes to store to the Exchange if there is already an existing Exchange present for this correlation key the implementation should throw an OptimisticLockingException. If theoldExchangeis not null the underlying implementation should use it to compare with the existing exchange when doing an atomic compare-and-set/swap operation. The implementation may achieve this by storing a version identifier in the Exchange as a parameter. Set before returning fromAggregationRepository.get(org.apache.camel.CamelContext, String)} and retrieved from the exchange when passed toAggregationRepository.add(org.apache.camel.CamelContext, String, org.apache.camel.Exchange). Note: Theis an exception to this recommendation. It uses theinvalid reference
org.apache.camel.processor.aggregate.MemoryAggregationRepositoryoldExchange's Object identify to perform it's compare-and-set/swap operation, instead of a version parameter. This is not the recommended approach, and should be avoided. Thewill ensure that the exchange received frominvalid reference
org.apache.camel.processor.aggregate.AggregateProcessorAggregationRepository.get(org.apache.camel.CamelContext, String)is passed asoldExchange, and that the aggregated exchange received from theis passed as theinvalid reference
org.apache.camel.processor.aggregate.AggregationStrategynewExchange.- Parameters:
camelContext- the current CamelContextkey- the correlation keyoldExchange- the old exchange that is expected to exist when replacing with the new exchangenewExchange- the new aggregated exchange, to replace old exchange- Returns:
- the old exchange if any existed
- Throws:
OptimisticLockingAggregationRepository.OptimisticLockingException- This should be thrown when the currently stored exchange differs from the supplied oldExchange.
-
remove
void remove(CamelContext camelContext, String key, Exchange exchange) throws OptimisticLockingAggregationRepository.OptimisticLockingException Removes the given Exchange when both the supplied key and Exchange are present in the repository. If the supplied Exchange does not match the Exchange actually stored against the key this method should throw an OptimisticLockingException to indicate that the value of the correlation key has changed from the expected value.- Specified by:
removein interfaceAggregationRepository- Parameters:
camelContext- the current CamelContextkey- the correlation keyexchange- the exchange to remove- Throws:
OptimisticLockingAggregationRepository.OptimisticLockingException- This should be thrown when the exchange has already been deleted, or otherwise modified.
-