use of org.springframework.integration.store.SimpleMessageStore in project spring-integration by spring-projects.
the class ClaimCheckTransformerTests method store.
@Test
public void store() {
MessageStore store = new SimpleMessageStore(10);
ClaimCheckInTransformer transformer = new ClaimCheckInTransformer(store);
Message<?> input = MessageBuilder.withPayload("test").build();
Message<?> output = transformer.transform(input);
assertEquals(input.getHeaders().getId(), output.getPayload());
}
use of org.springframework.integration.store.SimpleMessageStore in project spring-integration by spring-projects.
the class ClaimCheckTransformerTests method retrieve.
@Test
public void retrieve() {
MessageStore store = new SimpleMessageStore(10);
Message<?> message = MessageBuilder.withPayload("test").build();
UUID storedId = message.getHeaders().getId();
store.addMessage(message);
ClaimCheckOutTransformer transformer = new ClaimCheckOutTransformer(store);
Message<?> input = MessageBuilder.withPayload(storedId).build();
Message<?> output = transformer.transform(input);
assertEquals("test", output.getPayload());
}
use of org.springframework.integration.store.SimpleMessageStore in project spring-integration by spring-projects.
the class AggregatorTests method testAggPerf.
@Test
public void testAggPerf() throws InterruptedException, ExecutionException, TimeoutException {
AggregatingMessageHandler handler = new AggregatingMessageHandler(new DefaultAggregatingMessageGroupProcessor());
handler.setCorrelationStrategy(message -> "foo");
handler.setReleaseStrategy(new MessageCountReleaseStrategy(60000));
handler.setExpireGroupsUponCompletion(true);
handler.setSendPartialResultOnExpiry(true);
DirectChannel outputChannel = new DirectChannel();
handler.setOutputChannel(outputChannel);
final CompletableFuture<Collection<?>> resultFuture = new CompletableFuture<>();
outputChannel.subscribe(message -> {
Collection<?> payload = (Collection<?>) message.getPayload();
logger.warn("Received " + payload.size());
resultFuture.complete(payload);
});
SimpleMessageStore store = new SimpleMessageStore();
SimpleMessageGroupFactory messageGroupFactory = new SimpleMessageGroupFactory(SimpleMessageGroupFactory.GroupType.LIST);
store.setMessageGroupFactory(messageGroupFactory);
handler.setMessageStore(store);
Message<?> message = new GenericMessage<String>("foo");
StopWatch stopwatch = new StopWatch();
stopwatch.start();
for (int i = 0; i < 120000; i++) {
if (i % 10000 == 0) {
stopwatch.stop();
logger.warn("Sent " + i + " in " + stopwatch.getTotalTimeSeconds() + " (10k in " + stopwatch.getLastTaskTimeMillis() + "ms)");
stopwatch.start();
}
handler.handleMessage(message);
}
stopwatch.stop();
logger.warn("Sent " + 120000 + " in " + stopwatch.getTotalTimeSeconds() + " (10k in " + stopwatch.getLastTaskTimeMillis() + "ms)");
Collection<?> result = resultFuture.get(10, TimeUnit.SECONDS);
assertNotNull(result);
assertEquals(60000, result.size());
}
use of org.springframework.integration.store.SimpleMessageStore in project spring-integration by spring-projects.
the class ResequencerTests method testResequencingWithIncompleteSequenceRelease.
@Test
public void testResequencingWithIncompleteSequenceRelease() throws InterruptedException {
this.resequencer.setReleaseStrategy(new SequenceSizeReleaseStrategy(true));
// INT-3846
this.resequencer.setMessageStore(new SimpleMessageStore(3));
QueueChannel replyChannel = new QueueChannel();
Message<?> message1 = createMessage("123", "ABC", 4, 4, replyChannel);
Message<?> message2 = createMessage("456", "ABC", 4, 2, replyChannel);
// release 2 after this one
Message<?> message3 = createMessage("789", "ABC", 4, 1, replyChannel);
Message<?> message4 = createMessage("XYZ", "ABC", 4, 3, replyChannel);
this.resequencer.handleMessage(message1);
this.resequencer.handleMessage(message2);
this.resequencer.handleMessage(message3);
Message<?> reply1 = replyChannel.receive(0);
Message<?> reply2 = replyChannel.receive(0);
Message<?> reply3 = replyChannel.receive(0);
// only messages 1 and 2 should have been received by now
assertNotNull(reply1);
assertEquals(1, new IntegrationMessageHeaderAccessor(reply1).getSequenceNumber());
assertNotNull(reply2);
assertEquals(2, new IntegrationMessageHeaderAccessor(reply2).getSequenceNumber());
assertNull(reply3);
// when sending the last message, the whole sequence must have been sent
this.resequencer.handleMessage(message4);
reply3 = replyChannel.receive(0);
Message<?> reply4 = replyChannel.receive(0);
assertNotNull(reply3);
assertEquals(3, new IntegrationMessageHeaderAccessor(reply3).getSequenceNumber());
assertNotNull(reply4);
assertEquals(4, new IntegrationMessageHeaderAccessor(reply4).getSequenceNumber());
}
use of org.springframework.integration.store.SimpleMessageStore in project spring-integration by spring-projects.
the class DelayHandler method doInit.
@Override
protected void doInit() {
if (this.messageStore == null) {
this.messageStore = new SimpleMessageStore();
} else {
Assert.isInstanceOf(MessageStore.class, this.messageStore);
}
this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(this.getBeanFactory());
this.releaseHandler = this.createReleaseMessageTask();
}
Aggregations