use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.
the class RedisMessageGroupStoreTests method testMultipleInstancesOfGroupStore.
@Test
@RedisAvailable
public void testMultipleInstancesOfGroupStore() {
RedisConnectionFactory jcf = getConnectionFactoryForTest();
RedisMessageStore store1 = new RedisMessageStore(jcf);
RedisMessageStore store2 = new RedisMessageStore(jcf);
store1.removeMessageGroup(this.groupId);
Message<?> message = new GenericMessage<>("1");
store1.addMessagesToGroup(this.groupId, message);
MessageGroup messageGroup = store2.addMessageToGroup(this.groupId, new GenericMessage<>("2"));
assertEquals(2, messageGroup.getMessages().size());
RedisMessageStore store3 = new RedisMessageStore(jcf);
store3.removeMessagesFromGroup(this.groupId, message);
messageGroup = store3.getMessageGroup(this.groupId);
assertEquals(1, messageGroup.getMessages().size());
}
use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.
the class RedisMessageGroupStoreTests method testNonExistingEmptyMessageGroup.
@Test
@RedisAvailable
public void testNonExistingEmptyMessageGroup() {
RedisConnectionFactory jcf = getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
MessageGroup messageGroup = store.getMessageGroup(this.groupId);
assertNotNull(messageGroup);
assertTrue(messageGroup instanceof SimpleMessageGroup);
assertEquals(0, messageGroup.size());
}
use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.
the class RedisMessageGroupStoreTests method testMessageGroupUpdatedDateChangesWithEachAddedMessage.
@Test
@RedisAvailable
public void testMessageGroupUpdatedDateChangesWithEachAddedMessage() throws Exception {
RedisConnectionFactory jcf = getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
Message<?> message = new GenericMessage<>("Hello");
MessageGroup messageGroup = store.addMessageToGroup(this.groupId, message);
assertEquals(1, messageGroup.size());
long createdTimestamp = messageGroup.getTimestamp();
long updatedTimestamp = messageGroup.getLastModified();
assertEquals(createdTimestamp, updatedTimestamp);
Thread.sleep(10);
message = new GenericMessage<>("Hello");
messageGroup = store.addMessageToGroup(this.groupId, message);
createdTimestamp = messageGroup.getTimestamp();
updatedTimestamp = messageGroup.getLastModified();
assertTrue(updatedTimestamp > createdTimestamp);
// make sure the store is properly rebuild from Redis
store = new RedisMessageStore(jcf);
messageGroup = store.getMessageGroup(this.groupId);
assertEquals(2, messageGroup.size());
}
use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.
the class RedisMessageGroupStoreTests method testRemoveNonExistingMessageFromTheGroup.
@Test
@RedisAvailable
public void testRemoveNonExistingMessageFromTheGroup() {
RedisConnectionFactory jcf = getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
MessageGroup messageGroup = store.getMessageGroup(this.groupId);
store.addMessagesToGroup(messageGroup.getGroupId(), new GenericMessage<>("1"));
store.removeMessagesFromGroup(this.groupId, new GenericMessage<>("2"));
}
use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.
the class GemfireGroupStoreTests method testRemoveMessageFromTheGroup.
@Test
public void testRemoveMessageFromTheGroup() throws Exception {
GemfireMessageStore store = new GemfireMessageStore(region);
MessageGroup messageGroup = store.getMessageGroup(1);
Message<?> message = new GenericMessage<String>("2");
messageGroup = store.addMessageToGroup(messageGroup.getGroupId(), new GenericMessage<String>("1"));
messageGroup = store.getMessageGroup(1);
assertEquals(1, messageGroup.size());
// since it adds to a local region some times CREATED_DATE ends up to be the same
Thread.sleep(1);
// Unrealistic in a real scenario
messageGroup = store.addMessageToGroup(messageGroup.getGroupId(), message);
messageGroup = store.getMessageGroup(1);
assertEquals(2, messageGroup.size());
Thread.sleep(1);
messageGroup = store.addMessageToGroup(messageGroup.getGroupId(), new GenericMessage<String>("3"));
messageGroup = store.getMessageGroup(1);
assertEquals(3, messageGroup.size());
store.removeMessagesFromGroup(messageGroup.getGroupId(), message);
messageGroup = store.getMessageGroup(1);
assertEquals(2, messageGroup.size());
// make sure the store is properly rebuild from Gemfire
store = new GemfireMessageStore(region);
messageGroup = store.getMessageGroup(1);
assertEquals(2, messageGroup.size());
}
Aggregations