use of org.springframework.integration.store.SimpleMessageGroup in project spring-integration by spring-projects.
the class RedisMessageGroupStoreTests method testNonExistingEmptyMessageGroup.
@Test
@RedisAvailable
public void testNonExistingEmptyMessageGroup() {
RedisConnectionFactory jcf = getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
MessageGroup messageGroup = store.getMessageGroup(this.groupId);
assertNotNull(messageGroup);
assertTrue(messageGroup instanceof SimpleMessageGroup);
assertEquals(0, messageGroup.size());
}
use of org.springframework.integration.store.SimpleMessageGroup in project spring-integration by spring-projects.
the class ConfigurableMongoDbMessageStore method getMessageGroup.
@Override
public MessageGroup getMessageGroup(Object groupId) {
Assert.notNull(groupId, "'groupId' must not be null");
Query query = groupOrderQuery(groupId);
MessageDocument messageDocument = this.mongoTemplate.findOne(query, MessageDocument.class, this.collectionName);
if (messageDocument != null) {
long createdTime = messageDocument.getGroupCreatedTime();
long lastModifiedTime = messageDocument.getLastModifiedTime();
boolean complete = messageDocument.isComplete();
int lastReleasedSequence = messageDocument.getLastReleasedSequence();
MessageGroup messageGroup = getMessageGroupFactory().create(this, groupId, createdTime, complete);
messageGroup.setLastModified(lastModifiedTime);
messageGroup.setLastReleasedMessageSequenceNumber(lastReleasedSequence);
return messageGroup;
} else {
return new SimpleMessageGroup(groupId);
}
}
use of org.springframework.integration.store.SimpleMessageGroup in project spring-integration by spring-projects.
the class MongoDbMessageStore method getMessageGroup.
@Override
public MessageGroup getMessageGroup(Object groupId) {
Assert.notNull(groupId, "'groupId' must not be null");
Query query = whereGroupIdOrder(groupId);
MessageWrapper messageWrapper = this.template.findOne(query, MessageWrapper.class, this.collectionName);
if (messageWrapper != null) {
long createdTime = messageWrapper.get_Group_timestamp();
long lastModifiedTime = messageWrapper.get_Group_update_timestamp();
boolean complete = messageWrapper.get_Group_complete();
int lastReleasedSequence = messageWrapper.get_LastReleasedSequenceNumber();
MessageGroup messageGroup = getMessageGroupFactory().create(this, groupId, createdTime, complete);
messageGroup.setLastModified(lastModifiedTime);
messageGroup.setLastReleasedMessageSequenceNumber(lastReleasedSequence);
return messageGroup;
} else {
return new SimpleMessageGroup(groupId);
}
}
use of org.springframework.integration.store.SimpleMessageGroup in project spring-integration by spring-projects.
the class BarrierMessageHandler method buildResult.
/**
* Override to change the default mechanism by which the inbound and release messages
* are returned as a result.
* @param key The correlation key.
* @param requestMessage the inbound message.
* @param releaseMessage the release message.
* @return the result.
*/
protected Object buildResult(Object key, Message<?> requestMessage, Message<?> releaseMessage) {
SimpleMessageGroup group = new SimpleMessageGroup(key);
group.add(requestMessage);
group.add(releaseMessage);
return this.messageGroupProcessor.processMessageGroup(group);
}
use of org.springframework.integration.store.SimpleMessageGroup in project spring-integration by spring-projects.
the class SequenceSizeReleaseStrategyTests method testIncompleteList.
@Test
public void testIncompleteList() {
Message<String> message = MessageBuilder.withPayload("test1").setSequenceSize(2).build();
SimpleMessageGroup messages = new SimpleMessageGroup("FOO");
messages.add(message);
SequenceSizeReleaseStrategy releaseStrategy = new SequenceSizeReleaseStrategy();
assertFalse(releaseStrategy.canRelease(messages));
}
Aggregations