use of org.springframework.integration.store.SimpleMessageGroup in project spring-integration by spring-projects.
the class SequenceSizeReleaseStrategyTests method shouldPartiallyReleaseAsEarlyAsPossible.
@Test
public void shouldPartiallyReleaseAsEarlyAsPossible() {
SequenceSizeReleaseStrategy releaseStrategy = new SequenceSizeReleaseStrategy();
releaseStrategy.setReleasePartialSequences(true);
SimpleMessageGroup messages = new SimpleMessageGroup("FOO");
Message<String> message1 = MessageBuilder.withPayload("test1").setSequenceSize(5).setSequenceNumber(1).build();
Message<String> message2 = MessageBuilder.withPayload("test2").setSequenceSize(5).setSequenceNumber(2).build();
Message<String> message3 = MessageBuilder.withPayload("test3").setSequenceSize(5).setSequenceNumber(3).build();
Message<String> message4 = MessageBuilder.withPayload("test4").setSequenceSize(5).setSequenceNumber(4).build();
Message<String> message5 = MessageBuilder.withPayload("test5").setSequenceSize(5).setSequenceNumber(5).build();
messages.add(message5);
assertFalse(releaseStrategy.canRelease(messages));
messages.add(message1);
assertTrue(releaseStrategy.canRelease(messages));
messages.add(message2);
assertTrue(releaseStrategy.canRelease(messages));
messages.add(message3);
assertTrue(releaseStrategy.canRelease(messages));
messages.add(message4);
assertTrue(releaseStrategy.canRelease(messages));
}
use of org.springframework.integration.store.SimpleMessageGroup in project spring-integration by spring-projects.
the class SequenceSizeReleaseStrategyTests method shouldReleaseHeadOfSequenceDeliveredInOrder.
@Test
public void shouldReleaseHeadOfSequenceDeliveredInOrder() {
SequenceSizeReleaseStrategy releaseStrategy = new SequenceSizeReleaseStrategy();
releaseStrategy.setReleasePartialSequences(true);
SimpleMessageGroup messages = new SimpleMessageGroup("FOO");
assertTrue(releaseStrategy.canRelease(groupWithFirstMessagesOfIncompleteSequence(messages)));
}
use of org.springframework.integration.store.SimpleMessageGroup in project spring-integration by spring-projects.
the class ResequencingMessageGroupProcessorTests method shouldProcessSequence.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void shouldProcessSequence() {
Message prototypeMessage = MessageBuilder.withPayload("foo").setCorrelationId("x").setSequenceNumber(1).setSequenceSize(3).build();
List<Message<?>> messages = new ArrayList<Message<?>>();
Message message1 = MessageBuilder.fromMessage(prototypeMessage).setSequenceNumber(1).build();
Message message2 = MessageBuilder.fromMessage(prototypeMessage).setSequenceNumber(2).build();
Message message3 = MessageBuilder.fromMessage(prototypeMessage).setSequenceNumber(3).build();
messages.add(message1);
messages.add(message2);
messages.add(message3);
SimpleMessageGroup group = new SimpleMessageGroup(messages, "x");
List<Message> processedMessages = (List<Message>) processor.processMessageGroup(group);
assertThat(processedMessages, hasItems(message1, message2, message3));
}
use of org.springframework.integration.store.SimpleMessageGroup in project spring-integration by spring-projects.
the class TimeoutCountSequenceSizeReleaseStrategyTests method testIncompleteListWithTimeout.
@Test
public void testIncompleteListWithTimeout() {
Message<String> message = MessageBuilder.withPayload("test1").setSequenceSize(2).build();
SimpleMessageGroup messages = new SimpleMessageGroup("FOO");
messages.add(message);
TimeoutCountSequenceSizeReleaseStrategy releaseStrategy = new TimeoutCountSequenceSizeReleaseStrategy(TimeoutCountSequenceSizeReleaseStrategy.DEFAULT_THRESHOLD, -100);
assertTrue(releaseStrategy.canRelease(messages));
}
use of org.springframework.integration.store.SimpleMessageGroup in project spring-integration by spring-projects.
the class TimeoutCountSequenceSizeReleaseStrategyTests method testIncompleteList.
@Test
public void testIncompleteList() {
Message<String> message = MessageBuilder.withPayload("test1").setSequenceSize(2).build();
SimpleMessageGroup messages = new SimpleMessageGroup("FOO");
messages.add(message);
TimeoutCountSequenceSizeReleaseStrategy releaseStrategy = new TimeoutCountSequenceSizeReleaseStrategy();
assertFalse(releaseStrategy.canRelease(messages));
}
Aggregations