AWS SDK S3Waiter waitUntilObjectExists usage guidance

1.5k Views Asked by At

I am new to AWS S3 SDK and need guidance on using S3Waiter.waitUntilObjectExists() I could not find any exact examples. I have a S3 bucket in which every four hours files uploaded by upstream processes. I have while(true) loop which polls for this bucket but it seems to be unnecessary and doing lot of IOs.

I read about S3Waiter.waitUntilObjectExists() and it seems to be applicable and best practices kind of solution in my case.

1

There are 1 best solutions below

0
On

The examples for Amazon S3 V2 API are located in the AWS Doc Github repo. You will find the latest Java V2 examples that are tested via Unit tests, etc in Github:

https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javav2/example_code/s3/src/main/java/com/example/s3

For example, if you want to learn how to use waiters when you create a bucket, see this example:

https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javav2/example_code/s3/src/main/java/com/example/s3/CreateBucket.java

This concept is also explained in the AWS SDK for Java 2.x Developer guide:

Using waiters

And yes, using waiters is best practice vs looping and polling.