我正在使用与Redis的Spring集成。生产者使用redisqueueoutboundgateway,而在另一端,接收器具有用redisqueueinboundgateway定义的流。
从文件中我发现了以下句子
必须为任务执行器配置多个线程才能进行处理
我需要并发执行,以便加快请求的处理速度,但我可以看到始终有一个线程,即使我配置了如下自定义线程池任务执行器
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(5);
executor.setMaxPoolSize(40);
executor.setQueueCapacity(40);
executor.setThreadNamePrefix("QueueAsyncExecutor-");
executor.initialize();
return executor;
}
这个螺纹工具的用途是
final RedisQueueInboundGateway rqig = new RedisQueueInboundGateway(finalDestination, jedisConnectionFactory);
rqig.setTaskExecutor(getAsyncExecutor());
最后的结果是对请求进行顺序处理,所有这些处理都使用我从日志中看到的同一线程完成。在这种情况下,是否可以启用多线程处理?怎么用?