@@ -55,7 +55,7 @@ public class OutputDestination extends AbstractDestination {
|
||||
* @since 3.0.6
|
||||
*/
|
||||
public void clear() {
|
||||
this.messageQueues.clear();
|
||||
this.messageQueues.values().forEach(v -> v.clear());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,8 +66,9 @@ public class OutputDestination extends AbstractDestination {
|
||||
* @since 3.0.6
|
||||
*/
|
||||
public boolean clear(String destinationName) {
|
||||
if (StringUtils.hasText(destinationName) && this.messageQueues.containsKey(destinationName)) {
|
||||
this.messageQueues.clear();
|
||||
String queueName = destinationName.endsWith(".destination") ? destinationName : destinationName + ".destination";
|
||||
if (StringUtils.hasText(destinationName) && this.messageQueues.containsKey(queueName)) {
|
||||
this.messageQueues.get(queueName).clear();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -74,6 +74,30 @@ public class ScenarioTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2112() {
|
||||
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(
|
||||
TestChannelBinderConfiguration.getCompleteConfiguration(TestConfiguration.class))
|
||||
.web(WebApplicationType.NONE)
|
||||
.run("--spring.jmx.enabled=false",
|
||||
"--spring.cloud.function.definition=messageFunction")) {
|
||||
|
||||
InputDestination input = context.getBean(InputDestination.class);
|
||||
OutputDestination output = context.getBean(OutputDestination.class);
|
||||
|
||||
input.send(new GenericMessage<byte[]>("hello-1".getBytes()), "messageFunction-in-0");
|
||||
output.clear("messageFunction-out-0");
|
||||
input.send(new GenericMessage<byte[]>("hello-2".getBytes()), "messageFunction-in-0");
|
||||
assertThat(new String(output.receive(1000, "messageFunction-out-0").getPayload())).isEqualTo("hello-2");
|
||||
|
||||
input.send(new GenericMessage<byte[]>("hello-1".getBytes()), "messageFunction-in-0");
|
||||
input.send(new GenericMessage<byte[]>("hello-2".getBytes()), "messageFunction-in-0");
|
||||
output.clear();
|
||||
input.send(new GenericMessage<byte[]>("hello-3".getBytes()), "messageFunction-in-0");
|
||||
assertThat(new String(output.receive(1000, "messageFunction-out-0").getPayload())).isEqualTo("hello-3");
|
||||
}
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration
|
||||
@Configuration
|
||||
public static class TestConfiguration {
|
||||
|
||||
Reference in New Issue
Block a user