Search in sources :

Example 31 with SimpleMessageGroup

use of org.springframework.integration.store.SimpleMessageGroup in project spring-integration by spring-projects.

the class JdbcMessageStore method getMessageGroup.

@Override
public MessageGroup getMessageGroup(Object groupId) {
    String key = getKey(groupId);
    final AtomicReference<Date> createDate = new AtomicReference<Date>();
    final AtomicReference<Date> updateDate = new AtomicReference<Date>();
    final AtomicReference<Boolean> completeFlag = new AtomicReference<Boolean>();
    final AtomicReference<Integer> lastReleasedSequenceRef = new AtomicReference<Integer>();
    this.jdbcTemplate.query(getQuery(Query.GET_GROUP_INFO), rs -> {
        updateDate.set(rs.getTimestamp("UPDATED_DATE"));
        createDate.set(rs.getTimestamp("CREATED_DATE"));
        completeFlag.set(rs.getInt("COMPLETE") > 0);
        lastReleasedSequenceRef.set(rs.getInt("LAST_RELEASED_SEQUENCE"));
    }, key, this.region);
    if (createDate.get() == null && updateDate.get() == null) {
        return new SimpleMessageGroup(groupId);
    }
    MessageGroup messageGroup = getMessageGroupFactory().create(this, groupId, createDate.get().getTime(), completeFlag.get());
    messageGroup.setLastModified(updateDate.get().getTime());
    messageGroup.setLastReleasedMessageSequenceNumber(lastReleasedSequenceRef.get());
    return messageGroup;
}
Also used : MessageGroup(org.springframework.integration.store.MessageGroup) SimpleMessageGroup(org.springframework.integration.store.SimpleMessageGroup) AtomicReference(java.util.concurrent.atomic.AtomicReference) Date(java.util.Date) SimpleMessageGroup(org.springframework.integration.store.SimpleMessageGroup)

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