Added ChannelPollingMessageDispatcher for simplification (no need to set a ChannelPollingMessageRetriever on a dispatcher). The DefaultMessageDispatcher has been renamed BasePollingMessageDispatcher.
This commit is contained in:
@@ -27,14 +27,14 @@ import org.springframework.integration.message.Message;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* The default implementation of {@link MessageDispatcher}. If
|
||||
* The base implementation of a polling {@link MessageDispatcher}. If
|
||||
* {@link #broadcast} is set to <code>false</code> (the default), each message
|
||||
* will be sent to a single {@link MessageHandler}. Otherwise, each
|
||||
* retrieved {@link Message} will be sent to all handlers.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class DefaultMessageDispatcher extends AbstractMessageDispatcher {
|
||||
public class BasePollingMessageDispatcher extends AbstractMessageDispatcher {
|
||||
|
||||
private boolean broadcast = false;
|
||||
|
||||
@@ -45,7 +45,7 @@ public class DefaultMessageDispatcher extends AbstractMessageDispatcher {
|
||||
private boolean shouldFailOnRejectionLimit = true;
|
||||
|
||||
|
||||
public DefaultMessageDispatcher(MessageRetriever retriever) {
|
||||
public BasePollingMessageDispatcher(MessageRetriever retriever) {
|
||||
super(retriever);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2002-2007 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
|
||||
*
|
||||
* http://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.bus;
|
||||
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
|
||||
/**
|
||||
* A {@link MessageDispatcher} that polls a {@link MessageChannel}.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class ChannelPollingMessageDispatcher extends BasePollingMessageDispatcher {
|
||||
|
||||
public ChannelPollingMessageDispatcher(MessageChannel channel, int period) {
|
||||
this(channel, ConsumerPolicy.newPollingPolicy(period));
|
||||
}
|
||||
|
||||
public ChannelPollingMessageDispatcher(MessageChannel channel, ConsumerPolicy policy) {
|
||||
super(new ChannelPollingMessageRetriever(channel, policy));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -260,8 +260,7 @@ public class MessageBus implements ChannelRegistry, ApplicationContextAware, Lif
|
||||
|
||||
private void doActivate(MessageChannel channel, MessageHandler handler, ConsumerPolicy policy) {
|
||||
PooledMessageHandler pooledHandler = new PooledMessageHandler(handler, policy.getConcurrency(), policy.getMaxConcurrency());
|
||||
MessageRetriever retriever = new ChannelPollingMessageRetriever(channel, policy);
|
||||
DefaultMessageDispatcher dispatcher = new DefaultMessageDispatcher(retriever);
|
||||
ChannelPollingMessageDispatcher dispatcher = new ChannelPollingMessageDispatcher(channel, policy);
|
||||
dispatcher.setRejectionLimit(policy.getRejectionLimit());
|
||||
dispatcher.setRetryInterval(policy.getRetryInterval());
|
||||
dispatcher.addHandler(pooledHandler);
|
||||
|
||||
Reference in New Issue
Block a user