clebertsuconic commented on code in PR #5173: URL: https://github.com/apache/activemq-artemis/pull/5173#discussion_r1735003536
########## artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/mirror/AMQPMirrorControllerTarget.java: ########## @@ -177,6 +180,48 @@ public void onError(int errorCode, String errorMessage) { private AckManager ackManager; + /** This method will wait both replication and storage to finish their current operations. */ + public void flush() { + CountDownLatch latch = new CountDownLatch(1); + connection.runNow(() -> { + OperationContext oldContext = OperationContextImpl.getContext(); + try { + OperationContextImpl.setContext(mirrorContext); + mirrorContext.executeOnCompletion(new IOCallback() { + @Override + public void done() { + latch.countDown(); + } + + @Override + public void onError(int errorCode, String errorMessage) { + logger.warn("error code = {} / message = {}", errorCode, errorMessage); + latch.countDown(); + } + }); + } finally { + OperationContextImpl.setContext(oldContext); + } + }); + + long timeout; + try { + timeout = connection.getProtocolManager().getAckManagerFlushTimeout(); + } catch (Throwable e) { + logger.warn(e.getMessage(), e); + timeout = 10_000; + } Review Comment: I thought of potential issues in the integration-test suite... but even that.. it's theoretical. it's redundant code that is not meant to ever happen. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org For additional commands, e-mail: gitbox-h...@activemq.apache.org For further information, visit: https://activemq.apache.org/contact