我正在尝试配置一个监听器,以便在Amazon S3中上传文件时,为AWS SQS进行配置。我已经从S3配置了事件,因此当在S3中上传文件时,消息会被转储在SQS中。
现在我正在使用Spring Cloud(版本-1.2.1.RELEASE)来配置S3事件的SQS监听器。 以下是我的配置文件:aws-config.xml。
英译中:
现在我正在使用Spring Cloud(版本-1.2.1.RELEASE)来配置S3事件的SQS监听器。 以下是我的配置文件:aws-config.xml。
<aws-context:context-credentials>
<aws-context:simple-credentials access-key="*******" secret-key="******"/>
</aws-context:context-credentials>
<aws-context:context-region region="ap-south-1" />
<aws-context:context-resource-loader/>
<aws-messaging:annotation-driven-queue-listener max-number-of-messages="10"
wait-time-out="20" visibility-timeout="3600""/>
AwsResourceConfig.java
@Configuration
@EnableSqs
@ImportResource("classpath:/aws-config.xml")
@EnableRdsInstance(databaseName = "******",
dbInstanceIdentifier = "*****",
password = "******")
public class AwsResourceConfig {
@SqsListener(value = "souviksqs", deletionPolicy = SqsMessageDeletionPolicy.ON_SUCCESS)
public void receiveNewFileUpload(S3EventNotification event) {
try {
if ( event != null && !CollectionUtils.isNullOrEmpty( event.getRecords() ) && event.getRecords().get( 0 ) != null ) {
S3Entity entry = event.getRecords().get(0).getS3();
System.out.println("############ File Uploaded to ###################### " + entry.getBucket().getName() + "/" + entry.getObject().getKey());
}
} catch (Exception e) {
System.out.println("Error reading the SQS message " + e);
}
}
英译中:
每当在S3上传文件时,都会在SQS中添加一条消息。 但是SQSListener无法正常工作。
我漏掉了什么吗?