INT-4123: Add Prefix to the Key-Value MSs

Fixes spring-projects/spring-integration#2213
JIRA: https://jira.spring.io/browse/INT-4123

Fully different `MessageStore`s can be configured for the same shared
Key-Value data-base.
Since the retrieval logic is based on the keys, that may cause the
unexpected messages expiration via `MessageGroupStoreReaper`.

* To distinguish store instances on the shared store add `prefix`
option to the `AbstractKeyValueMessageStore`

* Deprecate the `GemfireMessageStore` `Cache`-based configuration - `setIgnoreJta()` and `afterPropertiesSet()`.
The `GemfireMessageStore` relies only on an externally configured `Region`.

**Cherry-pick to 4.3.x**

Doc Polishing
This commit is contained in:
Artem Bilan
2017-09-05 18:23:03 -04:00
committed by Gary Russell
parent df55ac95d8
commit 5263ea6dff
8 changed files with 176 additions and 111 deletions

View File

@@ -32,6 +32,7 @@ import org.junit.Before;
import org.junit.Test;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.BoundValueOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.history.MessageHistory;
@@ -53,7 +54,7 @@ public class RedisMessageStoreTests extends RedisAvailableTests {
@After
public void setUpTearDown() {
StringRedisTemplate template = this.createStringRedisTemplate(this.getConnectionFactoryForTest());
template.delete(template.keys("MESSAGE_*"));
template.delete(template.keys("*MESSAGE_*"));
}
@Test
@@ -122,6 +123,24 @@ public class RedisMessageStoreTests extends RedisAvailableTests {
assertEquals("Hello Redis", retrievedMessage.getPayload());
}
@SuppressWarnings("unchecked")
@Test
@RedisAvailable
public void testAddAndGetWithPrefix() {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf, "foo");
Message<String> stringMessage = new GenericMessage<String>("Hello Redis");
store.addMessage(stringMessage);
Message<String> retrievedMessage = (Message<String>) store.getMessage(stringMessage.getHeaders().getId());
assertNotNull(retrievedMessage);
assertEquals("Hello Redis", retrievedMessage.getPayload());
StringRedisTemplate template = createStringRedisTemplate(getConnectionFactoryForTest());
BoundValueOperations<String, String> ops =
template.boundValueOps("foo" + "MESSAGE_" + stringMessage.getHeaders().getId());
assertNotNull(ops.get());
}
@SuppressWarnings("unchecked")
@Test
@RedisAvailable