Daenyth Daenyth - 1 year ago 126
Java Question

How can I force AmazonSQSBufferedAsyncClient to flush messages?

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

method I can see on the client.

flush my messages when called? I looked at the source code and it's unclear. The method calls
on each
that it has, but inside
it says

public void shutdown() {
//send buffer does not require shutdown, only
//shut down receive buffer

Further, the documentation for

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
instead of the buffering/async one?

Answer Source

With 1.11.37 version of the SDK, there is a configuration parameter just for this purpose in QueueBufferConfig.

AmazonSQSBufferedAsyncClient bufClient =
    new AmazonSQSBufferedAsyncClient(
        new QueueBufferConfig( )
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download