use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.
the class JdbcMessageStoreTests method testCompleteMessageGroup.
@Test
public void testCompleteMessageGroup() throws Exception {
String groupId = "X";
Message<String> message = MessageBuilder.withPayload("foo").setCorrelationId(groupId).build();
messageStore.addMessagesToGroup(groupId, message);
messageStore.completeGroup(groupId);
MessageGroup group = messageStore.getMessageGroup(groupId);
assertTrue(group.isComplete());
assertEquals(1, group.size());
}
use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.
the class JdbcMessageStoreTests method testAddAndRemoveMessagesFromMessageGroup.
@Test
public void testAddAndRemoveMessagesFromMessageGroup() throws Exception {
String groupId = "X";
this.messageStore.setRemoveBatchSize(10);
List<Message<?>> messages = new ArrayList<Message<?>>();
for (int i = 0; i < 25; i++) {
Message<String> message = MessageBuilder.withPayload("foo").setCorrelationId(groupId).build();
messages.add(message);
}
this.messageStore.addMessagesToGroup(groupId, messages.toArray(new Message<?>[messages.size()]));
MessageGroup group = this.messageStore.getMessageGroup(groupId);
assertEquals(25, group.size());
this.messageStore.removeMessagesFromGroup(groupId, messages);
group = this.messageStore.getMessageGroup(groupId);
assertEquals(0, group.size());
}
use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.
the class JdbcMessageStoreTests method testAddAndGetMessageGroup.
@Test
public void testAddAndGetMessageGroup() throws Exception {
String groupId = "X";
Message<String> message = MessageBuilder.withPayload("foo").setCorrelationId(groupId).build();
long now = System.currentTimeMillis();
messageStore.addMessagesToGroup(groupId, message);
MessageGroup group = messageStore.getMessageGroup(groupId);
assertEquals(1, group.size());
assertTrue("Timestamp too early: " + group.getTimestamp() + "<" + now, group.getTimestamp() >= now);
}
use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.
the class JdbcMessageStoreTests method testUpdateLastReleasedSequence.
@Test
public void testUpdateLastReleasedSequence() throws Exception {
String groupId = "X";
Message<String> message = MessageBuilder.withPayload("foo").setCorrelationId(groupId).build();
messageStore.addMessagesToGroup(groupId, message);
messageStore.setLastReleasedSequenceNumberForGroup(groupId, 5);
MessageGroup group = messageStore.getMessageGroup(groupId);
assertEquals(5, group.getLastReleasedMessageSequenceNumber());
}
use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.
the class JdbcMessageStoreTests method testOrderInMessageGroup.
@Test
public void testOrderInMessageGroup() throws Exception {
String groupId = "X";
this.messageStore.addMessagesToGroup(groupId, MessageBuilder.withPayload("foo").setCorrelationId(groupId).build());
Thread.sleep(1);
this.messageStore.addMessagesToGroup(groupId, MessageBuilder.withPayload("bar").setCorrelationId(groupId).build());
MessageGroup group = this.messageStore.getMessageGroup(groupId);
assertEquals(2, group.size());
assertEquals("foo", this.messageStore.pollMessageFromGroup(groupId).getPayload());
assertEquals("bar", this.messageStore.pollMessageFromGroup(groupId).getPayload());
}
Aggregations