Rely on MProducerSupport.active for Flux (#3423)

* Rely on `MProducerSupport.active` for `Flux`

* Fix `MessageProducerSupport` to extract an `active` flag and set it before
`isRunning` - the `Flux` subscription relies on the `takeWhile()`
where in case of `autoStartup = false` we will never start consume because
it is set to `true` already after `doStart()`
* Refactor all the `MessageProducerSupport` implementation with similar
`active` state to use already one from the super class

**Cherry-pick to 5.3.x**

* * Remove `MessageProducerSupport.setActive()`
to not let to mutate it from the implementations
* Set `active` to `false` in the `destroy()`
* Clean up and fix typos in the affected `JmsMessageDrivenEndpoint`

* * Pull `active` flag down to the `AbstractEndpoint`
* Set `active = true` in the `start()` before calling `doStart()`
* Do same for `active = false` in the `stop()`
* Clean up `AbstractEndpoint` impls to not call `doStart/doStop` for nothing
* Refactor endpoints to rely on the `active` state from the `AbstractEndpoint`
not their own
This commit is contained in:
Artem Bilan
2020-11-06 13:51:03 -05:00
committed by Gary Russell
parent 27b464ad27
commit 002382e647
23 changed files with 1167 additions and 253 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.
@@ -30,6 +30,7 @@ import org.springframework.messaging.Message;
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 3.0
*
*/
@@ -84,19 +85,17 @@ public class TcpSyslogReceivingChannelAdapter extends SyslogReceivingChannelAdap
@Override
protected void doStart() {
super.doStart();
this.connectionFactory.start();
}
@Override
protected void doStop() {
super.doStop();
this.connectionFactory.stop();
}
@Override
public boolean onMessage(Message<?> message) {
this.convertAndSend(message);
convertAndSend(message);
return false;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.
@@ -24,6 +24,7 @@ import org.springframework.integration.ip.udp.UnicastReceivingChannelAdapter;
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 3.0
*
*/
@@ -33,8 +34,8 @@ public class UdpSyslogReceivingChannelAdapter extends SyslogReceivingChannelAdap
private volatile boolean udpAdapterSet;
public void setUdpAdapter(UnicastReceivingChannelAdapter udpAdpter) {
this.udpAdapter = udpAdpter;
public void setUdpAdapter(UnicastReceivingChannelAdapter udpAdapter) {
this.udpAdapter = udpAdapter;
this.udpAdapterSet = true;
}
@@ -65,7 +66,7 @@ public class UdpSyslogReceivingChannelAdapter extends SyslogReceivingChannelAdap
"of the provided 'UnicastReceivingChannelAdapter' to support Syslog conversion " +
"for the incoming UDP packets");
}
this.udpAdapter.setOutputChannel(new FixedSubscriberChannel(message -> convertAndSend(message)));
this.udpAdapter.setOutputChannel(new FixedSubscriberChannel(this::convertAndSend));
if (!this.udpAdapterSet) {
this.udpAdapter.afterPropertiesSet();
}
@@ -73,13 +74,11 @@ public class UdpSyslogReceivingChannelAdapter extends SyslogReceivingChannelAdap
@Override
protected void doStart() {
super.doStart();
this.udpAdapter.start();
}
@Override
protected void doStop() {
super.doStop();
this.udpAdapter.stop();
}