use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.
the class DelayHandlerTests method testRescheduleForTheDateDelay.
@Test
public void testRescheduleForTheDateDelay() throws Exception {
this.delayHandler.setDelayExpression(new SpelExpressionParser().parseExpression("payload"));
this.delayHandler.setOutputChannel(new DirectChannel());
this.delayHandler.setIgnoreExpressionFailures(false);
startDelayerHandler();
Calendar releaseDate = Calendar.getInstance();
releaseDate.add(Calendar.HOUR, 1);
this.delayHandler.handleMessage(new GenericMessage<>(releaseDate.getTime()));
// emulate restart
this.taskScheduler.destroy();
MessageGroupStore messageStore = TestUtils.getPropertyValue(this.delayHandler, "messageStore", MessageGroupStore.class);
MessageGroup messageGroup = messageStore.getMessageGroup(DELAYER_MESSAGE_GROUP_ID);
Message<?> messageInStore = messageGroup.getMessages().iterator().next();
Object payload = messageInStore.getPayload();
DirectFieldAccessor dfa = new DirectFieldAccessor(payload);
long requestTime = (long) dfa.getPropertyValue("requestDate");
Calendar requestDate = Calendar.getInstance();
requestDate.setTimeInMillis(requestTime);
requestDate.add(Calendar.HOUR, -2);
dfa.setPropertyValue("requestDate", requestDate.getTimeInMillis());
this.taskScheduler.afterPropertiesSet();
this.delayHandler.reschedulePersistedMessages();
Queue<?> works = TestUtils.getPropertyValue(this.taskScheduler, "scheduledExecutor.workQueue", Queue.class);
int n = 0;
while (n++ < 2000 && works.size() == 0) {
Thread.sleep(10);
}
assertEquals(1, works.size());
}
use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.
the class GemfireGroupStoreTests method testNonExistingEmptyMessageGroup.
@Test
public void testNonExistingEmptyMessageGroup() throws Exception {
GemfireMessageStore store = new GemfireMessageStore(region);
MessageGroup messageGroup = store.getMessageGroup(1);
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 GemfireGroupStoreTests method testRemoveNonExistingMessageFromTheGroup.
@Test
public void testRemoveNonExistingMessageFromTheGroup() throws Exception {
GemfireMessageStore store = new GemfireMessageStore(region);
MessageGroup messageGroup = store.getMessageGroup(1);
store.addMessagesToGroup(messageGroup.getGroupId(), new GenericMessage<String>("1"));
store.removeMessagesFromGroup(1, new GenericMessage<String>("2"));
}
use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.
the class GemfireGroupStoreTests method testRemoveMessageGroup.
@Test
public void testRemoveMessageGroup() throws Exception {
GemfireMessageStore store = new GemfireMessageStore(region);
MessageGroup messageGroup = store.getMessageGroup(1);
Message<?> message = new GenericMessage<String>("Hello");
messageGroup = store.addMessageToGroup(messageGroup.getGroupId(), message);
assertEquals(1, messageGroup.size());
store.removeMessageGroup(1);
MessageGroup messageGroupA = store.getMessageGroup(1);
assertNotSame(messageGroup, messageGroupA);
assertEquals(0, messageGroupA.getMessages().size());
assertEquals(0, messageGroupA.size());
// make sure the store is properly rebuild from Gemfire
store = new GemfireMessageStore(region);
messageGroup = store.getMessageGroup(1);
assertEquals(0, messageGroup.getMessages().size());
assertEquals(0, messageGroup.size());
}
use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.
the class GemfireGroupStoreTests method testLastReleasedSequenceNumber.
@Test
public void testLastReleasedSequenceNumber() throws Exception {
GemfireMessageStore store = new GemfireMessageStore(region);
MessageGroup messageGroup = store.getMessageGroup(1);
Message<?> messageToMark = new GenericMessage<String>("1");
store.addMessagesToGroup(messageGroup.getGroupId(), messageToMark);
store.setLastReleasedSequenceNumberForGroup(messageGroup.getGroupId(), 5);
messageGroup = store.getMessageGroup(1);
assertEquals(5, messageGroup.getLastReleasedMessageSequenceNumber());
}
Aggregations