INT-713
This commit is contained in:
@@ -36,6 +36,8 @@ public class PublishSubscribeChannel extends AbstractSubscribableChannel impleme
|
||||
|
||||
private volatile ErrorHandler errorHandler;
|
||||
|
||||
private volatile boolean applySequence;
|
||||
|
||||
|
||||
/**
|
||||
* Create a PublishSubscribeChannel that will use a {@link TaskExecutor}
|
||||
@@ -61,6 +63,7 @@ public class PublishSubscribeChannel extends AbstractSubscribableChannel impleme
|
||||
}
|
||||
|
||||
public void setApplySequence(boolean applySequence) {
|
||||
this.applySequence = applySequence;
|
||||
this.getDispatcher().setApplySequence(applySequence);
|
||||
}
|
||||
|
||||
@@ -73,6 +76,7 @@ public class PublishSubscribeChannel extends AbstractSubscribableChannel impleme
|
||||
this.taskExecutor = new ErrorHandlingTaskExecutor(this.taskExecutor, this.errorHandler);
|
||||
}
|
||||
this.dispatcher = new BroadcastingDispatcher(this.taskExecutor);
|
||||
this.dispatcher.setApplySequence(this.applySequence);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +81,25 @@ public class PublishSubscribeChannelParserTests {
|
||||
assertEquals(context.getBean("pool"), innerExecutor);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applySequenceEnabledWithTaskExecutor() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"publishSubscribeChannelParserTests.xml", this.getClass());
|
||||
PublishSubscribeChannel channel = (PublishSubscribeChannel)
|
||||
context.getBean("channelWithApplySequenceEnabledAndTaskExecutor");
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(channel);
|
||||
BroadcastingDispatcher dispatcher = (BroadcastingDispatcher)
|
||||
accessor.getPropertyValue("dispatcher");
|
||||
DirectFieldAccessor dispatcherAccessor = new DirectFieldAccessor(dispatcher);
|
||||
assertTrue((Boolean) dispatcherAccessor.getPropertyValue("applySequence"));
|
||||
TaskExecutor executor = (TaskExecutor) dispatcherAccessor.getPropertyValue("taskExecutor");
|
||||
assertNotNull(executor);
|
||||
assertEquals(ErrorHandlingTaskExecutor.class, executor.getClass());
|
||||
DirectFieldAccessor executorAccessor = new DirectFieldAccessor(executor);
|
||||
TaskExecutor innerExecutor = (TaskExecutor) executorAccessor.getPropertyValue("taskExecutor");
|
||||
assertEquals(context.getBean("pool"), innerExecutor);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void channelWithErrorHandler() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
<publish-subscribe-channel id="channelWithTaskExecutor" task-executor="pool"/>
|
||||
|
||||
<publish-subscribe-channel id="channelWithApplySequenceEnabledAndTaskExecutor" apply-sequence="true" task-executor="pool"/>
|
||||
|
||||
<publish-subscribe-channel id="channelWithErrorHandler" error-handler="testErrorHandler"/>
|
||||
|
||||
<thread-pool-task-executor id="pool" max-size="1"/>
|
||||
|
||||
Reference in New Issue
Block a user