INT-3475: Integer.MAX_VALUE / 2 Phase for MDEs
JIRA: https://jira.spring.io/browse/INT-3475 Change the phase for `SourcePollingChannelAdapterFactoryBean`, `AbstractPollingEndpoint`, `MessageProducerSupport`, `JmsMessageDrivenEndpoint` to the `Integer.MAX_VALUE / 2`
This commit is contained in:
committed by
Gary Russell
parent
5bb2141fe2
commit
7abefb08df
@@ -54,9 +54,11 @@ import org.springframework.util.StringUtils;
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Josh Long
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class ConsumerEndpointFactoryBean
|
||||
implements FactoryBean<AbstractEndpoint>, BeanFactoryAware, BeanNameAware, BeanClassLoaderAware, InitializingBean, SmartLifecycle {
|
||||
implements FactoryBean<AbstractEndpoint>, BeanFactoryAware, BeanNameAware, BeanClassLoaderAware,
|
||||
InitializingBean, SmartLifecycle {
|
||||
|
||||
private volatile MessageHandler handler;
|
||||
|
||||
@@ -70,6 +72,8 @@ public class ConsumerEndpointFactoryBean
|
||||
|
||||
private volatile int phase = 0;
|
||||
|
||||
private volatile boolean isPhaseSet;
|
||||
|
||||
private volatile MessageChannel inputChannel;
|
||||
|
||||
private volatile ConfigurableBeanFactory beanFactory;
|
||||
@@ -119,6 +123,7 @@ public class ConsumerEndpointFactoryBean
|
||||
|
||||
public void setPhase(int phase) {
|
||||
this.phase = phase;
|
||||
this.isPhaseSet = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -246,7 +251,8 @@ public class ConsumerEndpointFactoryBean
|
||||
pollingConsumer.setErrorHandler(this.pollerMetadata.getErrorHandler());
|
||||
|
||||
pollingConsumer.setReceiveTimeout(this.pollerMetadata.getReceiveTimeout());
|
||||
pollingConsumer.setTransactionSynchronizationFactory(this.pollerMetadata.getTransactionSynchronizationFactory());
|
||||
pollingConsumer.setTransactionSynchronizationFactory(
|
||||
this.pollerMetadata.getTransactionSynchronizationFactory());
|
||||
pollingConsumer.setBeanClassLoader(beanClassLoader);
|
||||
pollingConsumer.setBeanFactory(beanFactory);
|
||||
this.endpoint = pollingConsumer;
|
||||
@@ -257,7 +263,11 @@ public class ConsumerEndpointFactoryBean
|
||||
this.endpoint.setBeanName(this.beanName);
|
||||
this.endpoint.setBeanFactory(this.beanFactory);
|
||||
this.endpoint.setAutoStartup(this.autoStartup);
|
||||
this.endpoint.setPhase(this.phase);
|
||||
int phase = this.phase;
|
||||
if (!this.isPhaseSet && this.endpoint instanceof PollingConsumer) {
|
||||
phase = Integer.MAX_VALUE / 2;
|
||||
}
|
||||
this.endpoint.setPhase(phase);
|
||||
this.endpoint.afterPropertiesSet();
|
||||
this.initialized = true;
|
||||
}
|
||||
@@ -270,7 +280,7 @@ public class ConsumerEndpointFactoryBean
|
||||
|
||||
@Override
|
||||
public boolean isAutoStartup() {
|
||||
return (this.endpoint != null) ? this.endpoint.isAutoStartup() : true;
|
||||
return (this.endpoint == null) || this.endpoint.isAutoStartup();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -280,7 +290,7 @@ public class ConsumerEndpointFactoryBean
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return (this.endpoint != null) ? this.endpoint.isRunning() : false;
|
||||
return (this.endpoint != null) && this.endpoint.isRunning();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -303,4 +313,5 @@ public class ConsumerEndpointFactoryBean
|
||||
this.endpoint.stop(callback);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class SourcePollingChannelAdapterFactoryBean implements FactoryBean<Sourc
|
||||
|
||||
private volatile boolean autoStartup = true;
|
||||
|
||||
private volatile int phase = 0;
|
||||
private volatile int phase = Integer.MAX_VALUE / 2;
|
||||
|
||||
private volatile Long sendTimeout;
|
||||
|
||||
@@ -187,7 +187,7 @@ public class SourcePollingChannelAdapterFactoryBean implements FactoryBean<Sourc
|
||||
*/
|
||||
|
||||
public boolean isAutoStartup() {
|
||||
return (this.adapter != null) ? this.adapter.isAutoStartup() : true;
|
||||
return (this.adapter == null) || this.adapter.isAutoStartup();
|
||||
}
|
||||
|
||||
public int getPhase() {
|
||||
@@ -195,7 +195,7 @@ public class SourcePollingChannelAdapterFactoryBean implements FactoryBean<Sourc
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
return (this.adapter != null) ? this.adapter.isRunning() : false;
|
||||
return (this.adapter != null) && this.adapter.isRunning();
|
||||
}
|
||||
|
||||
public void start() {
|
||||
@@ -215,4 +215,5 @@ public class SourcePollingChannelAdapterFactoryBean implements FactoryBean<Sourc
|
||||
this.adapter.stop(callback);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public abstract class AbstractPollingEndpoint extends AbstractEndpoint implement
|
||||
private volatile TransactionSynchronizationFactory transactionSynchronizationFactory;
|
||||
|
||||
public AbstractPollingEndpoint() {
|
||||
this.setPhase(Integer.MAX_VALUE);
|
||||
this.setPhase(Integer.MAX_VALUE / 2);
|
||||
}
|
||||
|
||||
public void setTaskExecutor(Executor taskExecutor) {
|
||||
|
||||
@@ -44,6 +44,9 @@ public abstract class MessageProducerSupport extends AbstractEndpoint implements
|
||||
|
||||
private final MessagingTemplate messagingTemplate = new MessagingTemplate();
|
||||
|
||||
protected MessageProducerSupport() {
|
||||
this.setPhase(Integer.MAX_VALUE / 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOutputChannel(MessageChannel outputChannel) {
|
||||
|
||||
Reference in New Issue
Block a user