How to identify file from S3 with message in the queue.
Closed this issue · 2 comments
Hi, I am planning to use this library but I can't find any documentation on how we can find the related file in the bucket.
My use case is if some message fails to be processed or drops to the dead letter queue I would like to see and look through the contents of the file manually. Is it possible to achieve this with this library?
For a fallback mechanism you would need to implement it on your side.
So, if you're unable to retrieve the stored message that is in S3 using this library for whatever reason (or if you just want to look at the message), you'd have to implement the logic to access the S3 bucket where the message is stored. You can also just view the messages in the S3 UI console by going to the proper bucket.
When creating the client, you have to pass in the bucket to be used. example:
/*
* Create a new instance of the builder with all defaults (credentials
* and region) set automatically. For more information, see
* Creating Service Clients in the AWS SDK for Java Developer Guide.
*/
final AmazonS3 s3 = AmazonS3ClientBuilder.defaultClient();
/*
* Set the Amazon S3 bucket name, and then set a lifecycle rule on the
* bucket to permanently delete objects 14 days after each object's
* creation date.
*/
final BucketLifecycleConfiguration.Rule expirationRule =
new BucketLifecycleConfiguration.Rule();
expirationRule.withExpirationInDays(14).withStatus("Enabled");
final BucketLifecycleConfiguration lifecycleConfig =
new BucketLifecycleConfiguration().withRules(expirationRule);
// Create the bucket and allow message objects to be stored in the bucket.
s3.createBucket(S3_BUCKET_NAME);
s3.setBucketLifecycleConfiguration(S3_BUCKET_NAME, lifecycleConfig);
System.out.println("Bucket created and configured.");
/*
* Set the Amazon SQS extended client configuration with large payload
* support enabled.
*/
final ExtendedClientConfiguration extendedClientConfig =
new ExtendedClientConfiguration()
.withLargePayloadSupportEnabled(s3, S3_BUCKET_NAME)
.withAlwaysThroughS3(true);
So you can find the messages in that configured bucket, same way as you would when using S3 on it's own.
https://docs.aws.amazon.com/AmazonS3/latest/userguide/download-objects.html