I'm using the AWS SDK for Java and I'm using the buffering async sqs client to batch requests so that I reduce costs.
When my application shuts down, I want to ensure that no messages are waiting in the buffer, but there's no .flush()
method I can see on the client.
Does AmazonSQSBufferedAsyncClient.shutdown()
flush my messages when called? I looked at the source code and it's unclear. The method calls shutdown()
on each QueueBuffer
that it has, but inside QueueBuffer.shutdown()
it says
public void shutdown() {
//send buffer does not require shutdown, only
//shut down receive buffer
receiveBuffer.shutdown();
}
Further, the documentation for .shutdown()
says:
Shuts down this client object, releasing any resources that might be held open. This is an optional method, and callers are not expected to call it, but can if they want to explicitly release any open resources. Once a client has been shutdown, it should not be used to make any more requests.
For this application, I need to ensure no messages get lost while being buffered. Do I need to handle this manually using the normal AmazonSQSClient
instead of the buffering/async one?
With 1.11.37 version of the SDK, there is a configuration parameter just for this purpose in QueueBufferConfig
.
AmazonSQSBufferedAsyncClient bufClient =
new AmazonSQSBufferedAsyncClient(
realAsyncClient,
new QueueBufferConfig( )
.withFlushOnShutdown(true)
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With