Fixed JdbcMessageStore to reuse CREATED_DATE while updating UPDATED_DATE

  Added support for configuring MessageGroup timeout based on the idle time of the MessageGroup

  Changed updatedTimestamp to lastModified

  Added an assertion to AbsractMessageGroup.expireMessageGroups to check if lastModified is 0

  Changed attribute name in MessageWrapper in Mongo Message Store
This commit is contained in:
Oleg Zhurakousky
2011-11-21 04:54:13 -05:00
committed by Mark Fisher
parent d67736021a
commit 50d8caa1c3
10 changed files with 237 additions and 68 deletions

View File

@@ -62,6 +62,33 @@ public class RedisMessageGroupStoreTests extends RedisAvailableTests {
assertEquals(0, messageGroup.size());
}
@Test
@RedisAvailable
public void testMessageGroupUpdatedDateChangesWithEachAddedMessage() throws Exception{
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
MessageGroup messageGroup = store.getMessageGroup(1);
Message<?> message = new GenericMessage<String>("Hello");
messageGroup = store.addMessageToGroup(1, message);
assertEquals(1, messageGroup.size());
long createdTimestamp = messageGroup.getTimestamp();
long updatedTimestamp = messageGroup.getLastModified();
assertEquals(createdTimestamp, updatedTimestamp);
Thread.sleep(1000);
message = new GenericMessage<String>("Hello");
messageGroup = store.addMessageToGroup(1, 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(1);
assertEquals(2, messageGroup.size());
}
@Test
@RedisAvailable
public void testMessageGroupWithAddedMessage() throws Exception{