GH-1936 Add operations to clear destinations queues to OutputDestination
Resolves #1936
This commit is contained in:
@@ -24,6 +24,7 @@ import java.util.concurrent.LinkedTransferQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Implementation of binder endpoint that represents the target destination (e.g.,
|
||||
@@ -47,6 +48,30 @@ public class OutputDestination extends AbstractDestination {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will clear all output destinations.
|
||||
*
|
||||
* @since 3.0.6
|
||||
*/
|
||||
public void clear() {
|
||||
this.messageQueues.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Will clear output destination with specified name.
|
||||
*
|
||||
* @param destinationName the name of the output destination to be cleared.
|
||||
* @return true if attempt to clear specific destination is successful otherwise false.
|
||||
* @since 3.0.6
|
||||
*/
|
||||
public boolean clear(String destinationName) {
|
||||
if (StringUtils.hasText(destinationName) && this.messageQueues.containsKey(destinationName)) {
|
||||
this.messageQueues.clear();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Allows to access {@link Message}s received by this {@link OutputDestination}.
|
||||
* @param timeout how long to wait before giving up
|
||||
|
||||
Reference in New Issue
Block a user