我现在正在使用@EnableAsync和@Async注释在 Spring Boot 中使用多线程。我有服务 A(快)和服务 B(慢)。
如何为他们设置不同的池?因此,当有大量对 B 的调用时,应用程序仍然可以在与 B 不同的池中处理服务 A。
@Configuration
@EnableAsync
public class ServiceExecutorConfig implements AsyncConfigurer {
@Override
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setCorePoolSize(30);
taskExecutor.setMaxPoolSize(40);
taskExecutor.setQueueCapacity(10);
taskExecutor.initialize();
return taskExecutor;
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用 AWS CDK。当我部署时,根据 AWS 控制台中的 CloudFormation Events,resources(CfnTrigger)in在和createWorkflow之前初始化。造成哪种情况取决于这两者的资源。createDDBCrawlercreateS3Crawlercreate_failed(Entity not found)createWorkflow
所以我想知道:
AWS CDK 资源生成序列(因为我在函数中没有看到async或promise,所以 TypeScript 正在按顺序处理代码。那么它是 CDK/CloudFormation 行为?)
如何避免这种情况或安排资源创建顺序,除了创建两个堆栈之外。
export class QuicksightGlue extends Construct {
constructor(scope: Construct, name: string, props: QuicksightGlueProps) {
super(scope, name);
this.createGlueDb(props.glueDb);
for (let zone of zones) {
const ddbCrawler = this.createDDBCrawler(...);
const etlJob = this.createEtlJob(...);
// crawler for processed data
this.createS3Crawler(...);
// create workflow that use crawler
this.createWorkflow(...);
}
}
Run Code Online (Sandbox Code Playgroud)
private createS3Crawler(...) {
return new …Run Code Online (Sandbox Code Playgroud)