Added 'task-executor' awareness to the AbstractEndpointParser for polling consumer endpoints.

This commit is contained in:
Mark Fisher
2008-09-07 21:29:14 +00:00
parent bd7c74b69c
commit 1e43e9439d
2 changed files with 11 additions and 0 deletions

View File

@@ -94,6 +94,7 @@ public abstract class AbstractEndpointParser extends AbstractSingleBeanDefinitio
if (txElement != null) {
IntegrationNamespaceUtils.configureTransactionAttributes(txElement, builder);
}
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, pollerElement, "task-executor");
}
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, INPUT_CHANNEL_ATTRIBUTE);
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, OUTPUT_CHANNEL_ATTRIBUTE);

View File

@@ -17,6 +17,7 @@
package org.springframework.integration.endpoint;
import org.springframework.context.Lifecycle;
import org.springframework.core.task.TaskExecutor;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.channel.PollableChannel;
@@ -41,6 +42,8 @@ public abstract class AbstractMessageConsumingEndpoint extends AbstractEndpoint
private volatile ChannelPoller poller;
private volatile TaskExecutor taskExecutor;
private volatile int maxMessagesPerPoll = -1;
private volatile boolean initialized;
@@ -58,6 +61,10 @@ public abstract class AbstractMessageConsumingEndpoint extends AbstractEndpoint
this.schedule = schedule;
}
public void setTaskExecutor(TaskExecutor taskExecutor) {
this.taskExecutor = taskExecutor;
}
public void setMaxMessagesPerPoll(int maxMessagesPerPoll) {
this.maxMessagesPerPoll = maxMessagesPerPoll;
if (this.poller != null) {
@@ -76,6 +83,9 @@ public abstract class AbstractMessageConsumingEndpoint extends AbstractEndpoint
this.poller = new ChannelPoller((PollableChannel) this.inputChannel, this.schedule);
this.poller.setMaxMessagesPerPoll(this.maxMessagesPerPoll);
this.configureTransactionSettingsForPoller(this.poller);
if (this.taskExecutor != null) {
this.poller.setTaskExecutor(this.taskExecutor);
}
this.poller.subscribe(this);
}
this.initialized = true;