java - 测试 Camel 应用程序时如何模拟 Amazon SQS 终端节点
问题描述
我正在编写一个使用 Camel 来监听 SQS 队列的 Spring Boot 应用程序。路线定义:
from("aws-sqs://my-s3-notification-queue" +
"?amazonSQSClient=#sqsClient" +
"&deleteAfterRead=false")
.unmarshal().json(JsonLibrary.Jackson, S3EventNotification.class)
.bean(s3NotificationHandler);
sqsClient
@Bean
在@Configuration
文件中定义为 a 。
在运行测试时,我想模拟 SQS 端点,这样我就不会真正连接到 AWS。我该怎么做呢?我试过写我的测试,比如
@RunWith(CamelSpringBootRunner.class)
@SpringBootTest
@MockEndpoints
public class ApplicationTests {
@Test
public void contextLoads() {
}
}
如果我正确阅读文档,这应该可以工作,但它仍会尝试连接到 AWS。我错过了什么?
解决方案
您可以使用Localstack 使用它,您可以从本地系统模拟多个 AWS 服务,而无需连接 AWS。
推荐阅读
- typescript - 导入第 3 方库时,带有 TypeScript 的 Quasar (vuejs) 项目显示错误
- apache-spark - 在 Spark 数据框中,如何将行转置为列?
- image - 下载了 Imagenette2 数据集,但现在如何获取和提取?就像张量流加载自己的数据集一样?
- python - Heroku 为 Python 应用程序显示“构建成功”,但应用程序没有打开打开,只显示一个 Heroku“默认页面”
- flutter - 颤振的 Speedtest Cli
- indexing - 是否可以在 ArangoDB 中的子键上创建唯一约束?
- python - 在python中比较两个彼此相反的列表
- c# - 在 WPF 中的 Command 中更改 DataContext 的值
- c# - 自定义 BindingNavigator 的 ToolStripButtons 在表单设计器中显示为锁定
- javascript - JavaScript while loop + setInterval 在 Django 中不起作用