org.springframework.integration.aggregator.CorrelatingMessageBarrier Maven / Gradle / Ivy
/*
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.aggregator;
import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.handler.AbstractMessageHandler;
import org.springframework.integration.store.MessageGroup;
import org.springframework.integration.store.MessageGroupStore;
import org.springframework.integration.store.SimpleMessageStore;
import org.springframework.messaging.Message;
/**
* This Endpoint serves as a barrier for messages that should not be processed yet. The decision when a message can be
* processed is delegated to a {@link org.springframework.integration.aggregator.ReleaseStrategy ReleaseStrategy}.
* When a message can be processed it is up to the client to take care of the locking (potentially from the ReleaseStrategy's
* {@link org.springframework.integration.aggregator.ReleaseStrategy#canRelease(org.springframework.integration.store.MessageGroup) canRelease(..)}
* method).
*
* This class differs from AbstractCorrelatingMessageHandler in that it completely decouples the receiver and the sender. It can
* be applied in scenarios where completion of a message group is not well defined but only a certain amount of messages
* for any given correlation key may be processed at a time.
*
* The messages will be stored in a {@link org.springframework.integration.store.MessageGroupStore MessageStore}
* for each correlation key.
*
* @author Iwein Fuld
* @author Oleg Zhurakousky
* @author Gary Russell
*
* @see AbstractCorrelatingMessageHandler
*/
public class CorrelatingMessageBarrier extends AbstractMessageHandler implements MessageSource