SQS Listener for S3 CreateEvent in AWS Java SDK v2

365 views Asked by At

In our Java Spring Boot application using aws-spring-cloud v2.4.4 and AWS SDK v1 we have the following code which listens for S3 Events, checks whether the Event Name of the triggering event is "ObjectCreated" and if so performs an action....

@SqsListener(value = "[the physical id]", deletionPolicy = SqsMessageDeletionPolicy.ON_SUCCESS)
    public void handleMessage(final S3EventNotification s3EventNotification) throws IOException {
        final List<S3EventNotification.S3EventNotificationRecord> records = 
           s3EventNotification.getRecords();
        if (records.get(0).getEventName().startsWith("ObjectCreated"))) {
           [process the S3 createObject event]

Given that the class "S3EventNotification" does not exist any more in AWS SDK v2, how can I rewrite the above method when migrating to v2?

1

There are 1 answers

0
rlhagerm On BEST ANSWER

It looks like this is an issue that is being tracked here for the Java v2 SDK. There are also several workarounds in that thread that you may find helpful, including importing the definition from v1 or adding the class yourself.