IN PROGRESS - issue INT-567: Add round-robin dispatching strategy
http://jira.springframework.org/browse/INT-567 - Renamed LoadBalancingDispatcher to more explicit RoundRobinDispatcher - Removed round-robin option from xsd (not specifying a dispatcher yields the same)
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
package org.springframework.integration.channel;
|
||||
|
||||
import org.springframework.integration.dispatcher.AbstractWinningHandlerDispatcher;
|
||||
import org.springframework.integration.dispatcher.LoadBalancingDispatcher;
|
||||
import org.springframework.integration.dispatcher.RoundRobinDispatcher;
|
||||
|
||||
/**
|
||||
* A channel that invokes a single subscriber for each sent Message.
|
||||
@@ -30,8 +30,9 @@ import org.springframework.integration.dispatcher.LoadBalancingDispatcher;
|
||||
public class DirectChannel extends AbstractSubscribableChannel<AbstractWinningHandlerDispatcher> {
|
||||
|
||||
public DirectChannel() {
|
||||
super(new LoadBalancingDispatcher());
|
||||
super(new RoundRobinDispatcher());
|
||||
}
|
||||
|
||||
public DirectChannel(AbstractWinningHandlerDispatcher dispatcher){
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class PointToPointChannelParser extends AbstractChannelParser {
|
||||
|
||||
private void parseDispatcher(String dispatcherAttribute, BeanDefinitionBuilder builder, ParserContext parserContext) {
|
||||
if (dispatcherAttribute != null) {
|
||||
if (dispatcherAttribute.equals("fail-over")) {
|
||||
if (dispatcherAttribute.equals("failover")) {
|
||||
BeanDefinitionBuilder dispatcherBuilder = BeanDefinitionBuilder
|
||||
.genericBeanDefinition(DISPATCHER_PACKAGE + ".FailOverDispatcher");
|
||||
dispatcherBuilder.setRole(BeanDefinition.ROLE_SUPPORT);
|
||||
|
||||
@@ -166,9 +166,19 @@
|
||||
<xsd:attribute name="datatype" type="xsd:string" />
|
||||
<xsd:attribute name="dispatcher">
|
||||
<xsd:simpleType>
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Defines a dispatching strategy for the channel. The default is a round
|
||||
robin load balancer. In case of a publish subscribe channel this
|
||||
attribute will be ignored.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="fail-over" />
|
||||
<xsd:enumeration value="round-robin" />
|
||||
<xsd:enumeration value="failover" />
|
||||
<!--
|
||||
now the other (default) option is round robin load balancing we
|
||||
can add more options later
|
||||
-->
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
*
|
||||
* @author Iwein Fuld
|
||||
*/
|
||||
public class LoadBalancingDispatcher extends AbstractWinningHandlerDispatcher {
|
||||
public class RoundRobinDispatcher extends AbstractWinningHandlerDispatcher {
|
||||
|
||||
private AtomicInteger currentHandlerIndex = new AtomicInteger();
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.core.MessagePriority;
|
||||
import org.springframework.integration.dispatcher.FailOverDispatcher;
|
||||
import org.springframework.integration.dispatcher.LoadBalancingDispatcher;
|
||||
import org.springframework.integration.dispatcher.RoundRobinDispatcher;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.integration.message.MessageDeliveryException;
|
||||
@@ -75,7 +75,7 @@ public class ChannelParserTests {
|
||||
MessageChannel channel = (MessageChannel) context.getBean("defaultChannel");
|
||||
assertEquals(DirectChannel.class, channel.getClass());
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(channel);
|
||||
assertThat(accessor.getPropertyValue("dispatcher"), is(LoadBalancingDispatcher.class));
|
||||
assertThat(accessor.getPropertyValue("dispatcher"), is(RoundRobinDispatcher.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
<channel id="defaultChannel" />
|
||||
|
||||
<channel id="failOverChannel" dispatcher="fail-over"/>
|
||||
<channel id="failOverChannel" dispatcher="failover"/>
|
||||
|
||||
<publish-subscribe-channel id="publishSubscribeChannel" />
|
||||
|
||||
|
||||
@@ -16,11 +16,11 @@ import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
@RunWith(MockitoJUnit44Runner.class)
|
||||
public class LoadBalancingDispatcherConcurrentTests {
|
||||
public class RoundRobinDispatcherConcurrentTests {
|
||||
|
||||
private static final int TOTAL_EXECUTIONS = 40;
|
||||
|
||||
private AbstractWinningHandlerDispatcher dispatcher = new LoadBalancingDispatcher();
|
||||
private AbstractWinningHandlerDispatcher dispatcher = new RoundRobinDispatcher();
|
||||
|
||||
private ThreadPoolTaskExecutor scheduler = new ThreadPoolTaskExecutor();
|
||||
|
||||
@@ -33,9 +33,9 @@ import org.springframework.integration.message.MessageHandler;
|
||||
*
|
||||
*/
|
||||
@RunWith(MockitoJUnit44Runner.class)
|
||||
public class LoadBalancingDispatcherTests {
|
||||
public class RoundRobinDispatcherTests {
|
||||
|
||||
private AbstractWinningHandlerDispatcher dispatcher = new LoadBalancingDispatcher();
|
||||
private AbstractWinningHandlerDispatcher dispatcher = new RoundRobinDispatcher();
|
||||
|
||||
@Mock
|
||||
private MessageHandler handler;
|
||||
Reference in New Issue
Block a user