OPEN - issue INT-567: Add round-robin dispatching strategy

http://jira.springframework.org/browse/INT-567

Properly named AbstractUnicastDispatcher
This commit is contained in:
Iwein Fuld
2009-03-10 13:55:53 +00:00
parent efea914ed1
commit 0b4982b3de
6 changed files with 25 additions and 10 deletions

View File

@@ -16,7 +16,7 @@
package org.springframework.integration.channel;
import org.springframework.integration.dispatcher.AbstractHandleOnceDispatcher;
import org.springframework.integration.dispatcher.AbstractUnicastDispatcher;
import org.springframework.integration.dispatcher.RoundRobinDispatcher;
/**
@@ -27,13 +27,13 @@ import org.springframework.integration.dispatcher.RoundRobinDispatcher;
* @author Mark Fisher
* @author Iwein Fuld
*/
public class DirectChannel extends AbstractSubscribableChannel<AbstractHandleOnceDispatcher> {
public class DirectChannel extends AbstractSubscribableChannel<AbstractUnicastDispatcher> {
public DirectChannel() {
super(new RoundRobinDispatcher());
}
public DirectChannel(AbstractHandleOnceDispatcher dispatcher){
public DirectChannel(AbstractUnicastDispatcher dispatcher){
super(dispatcher);
}

View File

@@ -1,3 +1,17 @@
/* Copyright 2002-2008 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.dispatcher;
import java.util.Iterator;
@@ -23,9 +37,10 @@ import org.springframework.integration.message.MessageRejectedException;
* will be tried through the implementation of the {@link #getHandlerIterator(List)} method.
*
* @author Iwein Fuld
* @author Mark Fisher
*
*/
public abstract class AbstractHandleOnceDispatcher extends AbstractDispatcher {
public abstract class AbstractUnicastDispatcher extends AbstractDispatcher {
public final boolean dispatch(Message<?> message) {
boolean success = false;

View File

@@ -22,13 +22,13 @@ import java.util.List;
import org.springframework.integration.message.MessageHandler;
/**
* {@link AbstractHandleOnceDispatcher} that will try it's handlers in the
* {@link AbstractUnicastDispatcher} that will try it's handlers in the
* same order every dispatch.
*
* @author Mark Fisher
* @author Iwein Fuld
*/
public class FailOverDispatcher extends AbstractHandleOnceDispatcher {
public class FailOverDispatcher extends AbstractUnicastDispatcher {
@Override

View File

@@ -23,13 +23,13 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.springframework.integration.message.MessageHandler;
/**
* Round-robin implementation of {@link AbstractHandleOnceDispatcher}. This
* Round-robin implementation of {@link AbstractUnicastDispatcher}. This
* implementation will keep track of the index of the handler that has been
* tried first and use a different starting handler every dispatch.
*
* @author Iwein Fuld
*/
public class RoundRobinDispatcher extends AbstractHandleOnceDispatcher {
public class RoundRobinDispatcher extends AbstractUnicastDispatcher {
private AtomicInteger currentHandlerIndex = new AtomicInteger();

View File

@@ -22,7 +22,7 @@ public class RoundRobinDispatcherConcurrentTests {
private static final int TOTAL_EXECUTIONS = 40;
private AbstractHandleOnceDispatcher dispatcher = new RoundRobinDispatcher();
private AbstractUnicastDispatcher dispatcher = new RoundRobinDispatcher();
private ThreadPoolTaskExecutor scheduler = new ThreadPoolTaskExecutor();

View File

@@ -35,7 +35,7 @@ import org.springframework.integration.message.MessageHandler;
@RunWith(MockitoJUnit44Runner.class)
public class RoundRobinDispatcherTests {
private AbstractHandleOnceDispatcher dispatcher = new RoundRobinDispatcher();
private AbstractUnicastDispatcher dispatcher = new RoundRobinDispatcher();
@Mock
private MessageHandler handler;