INT-330: BufferingMessageHandler -> CorrelatingMessageHandler and MessagesProcessor -> MessageGroupProcessor
This commit is contained in:
@@ -39,13 +39,13 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
*
|
||||
* @author Iwein Fuld
|
||||
*/
|
||||
public class BufferingMessageHandler extends AbstractMessageHandler implements Lifecycle {
|
||||
public class CorrelatingMessageHandler extends AbstractMessageHandler implements Lifecycle {
|
||||
|
||||
private MessageStore store = new SimpleMessageStore(100);
|
||||
private final CorrelationStrategy correlationStrategy;
|
||||
private final IdTracker tracker = new IdTracker();
|
||||
private final CompletionStrategy completionStrategy;
|
||||
private MessagesProcessor outputProcessor;
|
||||
private MessageGroupProcessor outputProcessor;
|
||||
private MessageChannel outputChannel;
|
||||
private volatile MessageChannel discardChannel = new NullChannel();
|
||||
private TaskScheduler taskScheduler;
|
||||
@@ -57,10 +57,10 @@ public class BufferingMessageHandler extends AbstractMessageHandler implements L
|
||||
private volatile boolean sendPartialResultOnTimeout;
|
||||
private ChannelResolver channelResolver;
|
||||
|
||||
public BufferingMessageHandler(MessageStore store,
|
||||
public CorrelatingMessageHandler(MessageStore store,
|
||||
CorrelationStrategy correlationStrategy,
|
||||
CompletionStrategy completionStrategy,
|
||||
MessagesProcessor processor) {
|
||||
MessageGroupProcessor processor) {
|
||||
Assert.notNull(store);
|
||||
Assert.notNull(correlationStrategy);
|
||||
Assert.notNull(completionStrategy);
|
||||
@@ -71,8 +71,8 @@ public class BufferingMessageHandler extends AbstractMessageHandler implements L
|
||||
this.outputProcessor = processor;
|
||||
}
|
||||
|
||||
public BufferingMessageHandler(MessageStore store,
|
||||
MessagesProcessor processor) {
|
||||
public CorrelatingMessageHandler(MessageStore store,
|
||||
MessageGroupProcessor processor) {
|
||||
this(store, new HeaderAttributeCorrelationStrategy(
|
||||
MessageHeaders.CORRELATION_ID),
|
||||
new SequenceSizeCompletionStrategy(), processor);
|
||||
@@ -27,7 +27,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
/**
|
||||
* @author Iwein Fuld
|
||||
*/
|
||||
public class DefaultResequencerStrategies implements CorrelationStrategy, CompletionStrategy, MessagesProcessor {
|
||||
public class DefaultResequencerStrategies implements CorrelationStrategy, CompletionStrategy, MessageGroupProcessor {
|
||||
private final ConcurrentMap<Object, AtomicInteger> nextMessagesToPass = new ConcurrentHashMap<Object, AtomicInteger>();
|
||||
private volatile DefaultResequencerStrategies.SequenceNumberComparator sequenceSizeComparator = new SequenceNumberComparator();
|
||||
private volatile boolean releasePartialSequences;
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.Collection;
|
||||
/**
|
||||
* @author Iwein Fuld
|
||||
*/
|
||||
public interface MessagesProcessor {
|
||||
public interface MessageGroupProcessor {
|
||||
|
||||
void processAndSend(Object correlationKey,
|
||||
Collection<Message<?>> messagesUpForProcessing,
|
||||
@@ -3,12 +3,11 @@ package org.springframework.integration.aggregator;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.integration.core.MessageHeaders;
|
||||
import org.springframework.integration.handler.MethodInvokingMessageProcessor;
|
||||
import org.springframework.integration.store.MessageStore;
|
||||
import org.springframework.integration.store.SimpleMessageStore;
|
||||
|
||||
public class MethodInvokingAggregatorFactoryBean implements
|
||||
FactoryBean<BufferingMessageHandler> , InitializingBean{
|
||||
FactoryBean<CorrelatingMessageHandler> , InitializingBean{
|
||||
|
||||
private static final int DEFAULT_CAPACITY = Integer.MAX_VALUE;
|
||||
|
||||
@@ -19,7 +18,7 @@ public class MethodInvokingAggregatorFactoryBean implements
|
||||
|
||||
private CompletionStrategy completionStrategy = new SequenceSizeCompletionStrategy();
|
||||
|
||||
private MessagesProcessor processor;
|
||||
private MessageGroupProcessor processor;
|
||||
|
||||
private Object target;
|
||||
|
||||
@@ -33,13 +32,13 @@ public class MethodInvokingAggregatorFactoryBean implements
|
||||
// build processor
|
||||
}
|
||||
|
||||
public BufferingMessageHandler getObject() throws Exception {
|
||||
return new BufferingMessageHandler(store, correlationStrategy,
|
||||
public CorrelatingMessageHandler getObject() throws Exception {
|
||||
return new CorrelatingMessageHandler(store, correlationStrategy,
|
||||
completionStrategy, processor);
|
||||
}
|
||||
|
||||
public Class<? extends BufferingMessageHandler> getObjectType() {
|
||||
return BufferingMessageHandler.class;
|
||||
public Class<? extends CorrelatingMessageHandler> getObjectType() {
|
||||
return CorrelatingMessageHandler.class;
|
||||
}
|
||||
|
||||
public boolean isSingleton() {
|
||||
|
||||
@@ -11,14 +11,14 @@ import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
|
||||
public class MethodInvokingMessagesProcessor implements MessagesProcessor {
|
||||
public class MethodInvokingMessageGroupProcessor implements MessageGroupProcessor {
|
||||
|
||||
private final Object target;
|
||||
private final Method method;
|
||||
|
||||
private final MessageListMethodAdapter adapter;
|
||||
|
||||
public MethodInvokingMessagesProcessor(Object target) {
|
||||
public MethodInvokingMessageGroupProcessor(Object target) {
|
||||
this.target = target;
|
||||
this.method = selectMethodFrom(target);
|
||||
this.adapter = new MessageListMethodAdapter(target, method);
|
||||
@@ -5,7 +5,7 @@ import org.springframework.integration.core.MessageChannel;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class PassThroughMessagesProcessor implements MessagesProcessor {
|
||||
public class PassThroughMessageGroupProcessor implements MessageGroupProcessor {
|
||||
|
||||
public void processAndSend(Object correlationKey, Collection<Message<?>> messagesUpForProcessing, MessageChannel outputChannel, BufferedMessagesCallback processedCallback) {
|
||||
for (Message<?> message : messagesUpForProcessing) {
|
||||
Reference in New Issue
Block a user