我在AWS Elasic Beanstalk中运行的spring-boot应用程序从Amazon S3中的某个位置加载数据 . 数据每10分钟刷新一次,我希望beanstalk的所有实例都从S3重新加载数据 .

我有一个hacky方式来完成这件事 . 我做了以下 .

1. Implemented an end point in beanstalk application which, when called, triggers the reload.
2. I have a script that determines the IP address of each beanstalk instance given the beanstalk application's `environment name`.
3. I then iterate through all these IP addresses and call the end point mentioned in point 1 above.

到目前为止,这是有效的,因为实例的IP地址是公开可寻址的 . 由于我们不得不仅使用私有IP,因此不再是这种情况 .

什么是触发数据重新加载的正确方法?我在考虑以下几点:

1. Set up Amazon S3 bucket to generate an event and post to a SNS topic.
2. Have an SNS client in my beanstalk application which subscribes to that topic and listens for events.
3. Upon receiving an event from that topic, trigger the data reload.

我做过(1)但不知道怎么做(2)和(3) . 如何在Java代码中订阅该主题? SNS只允许3种通知方法 - 使用SQS(AWS简单排队服务),SMS和HTTP / HTTPS URL .

URL方法不起作用,因为它会将请求转发到负载均衡器后面的一个实例 . 因此,并非所有实例都会重新加载 .

SQS也不起作用,因为一旦一个实例读取消息,消息将被排队,其他实例将不会收到触发消息 .

电子邮件也不起作用(或者我不知道如何使它工作) .

任何帮助/想法?指向Java代码的指针将非常感激 .