Search in sources :

Example 16 with SimpleMessageGroup

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());
}
Also used : MessageGroup(org.springframework.integration.store.MessageGroup) SimpleMessageGroup(org.springframework.integration.store.SimpleMessageGroup) RedisConnectionFactory(org.springframework.data.redis.connection.RedisConnectionFactory) SimpleMessageGroup(org.springframework.integration.store.SimpleMessageGroup) RedisAvailable(org.springframework.integration.redis.rules.RedisAvailable) Test(org.junit.Test)

Example 17 with SimpleMessageGroup

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);
    }
}
Also used : Query(org.springframework.data.mongodb.core.query.Query) MessageGroup(org.springframework.integration.store.MessageGroup) SimpleMessageGroup(org.springframework.integration.store.SimpleMessageGroup) SimpleMessageGroup(org.springframework.integration.store.SimpleMessageGroup)

Example 18 with SimpleMessageGroup

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);
    }
}
Also used : Query(org.springframework.data.mongodb.core.query.Query) MessageGroup(org.springframework.integration.store.MessageGroup) SimpleMessageGroup(org.springframework.integration.store.SimpleMessageGroup) SimpleMessageGroup(org.springframework.integration.store.SimpleMessageGroup)

Example 19 with SimpleMessageGroup

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);
}
Also used : SimpleMessageGroup(org.springframework.integration.store.SimpleMessageGroup)

Example 20 with SimpleMessageGroup

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));
}
Also used : SimpleMessageGroup(org.springframework.integration.store.SimpleMessageGroup) Test(org.junit.Test)

Aggregations

SimpleMessageGroup (org.springframework.integration.store.SimpleMessageGroup)31 Test (org.junit.Test)21 MessageGroup (org.springframework.integration.store.MessageGroup)13 Message (org.springframework.messaging.Message)8 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 List (java.util.List)6 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)3 Method (java.lang.reflect.Method)2 Query (org.springframework.data.mongodb.core.query.Query)2 QueueChannel (org.springframework.integration.channel.QueueChannel)2 MessageGroupStore (org.springframework.integration.store.MessageGroupStore)2 Date (java.util.Date)1 Map (java.util.Map)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 RedisConnectionFactory (org.springframework.data.redis.connection.RedisConnectionFactory)1 MethodInvokingReleaseStrategy (org.springframework.integration.aggregator.MethodInvokingReleaseStrategy)1 ReleaseStrategy (org.springframework.integration.aggregator.ReleaseStrategy)1 ResequencingMessageHandler (org.springframework.integration.aggregator.ResequencingMessageHandler)1 EventDrivenConsumer (org.springframework.integration.endpoint.EventDrivenConsumer)1