为了提高性能,我建议使用带有任务 Actuator 的executorchannel来控制线程池大小的数量 . 通过这种方式,您可以获得消息到达jms队列时消费者接收消息并在单独的线程中处理流的情况 . 请记住,在这种配置中,多线程工作由taskexecutor通道执行taht将在单独的线程中执行消息的重新生成,因此您已经想到了您想要的多线程等级 .
对于队列消息通道,确实需要轮询器在通道上轮询以执行recive,队列容量是幕后原子队列的容量 .
您可以在xml中以这种方式配置执行程序通道
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:si="http://www.springframework.org/schema/integration"
xmlns:tx="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">
或者以这种方式在java-dsl中
@Bean
public IntegrationFlow storeBookPageByPage(ConnectionFactory connectionFactory,
@Qualifier("createBookQueue") Destination createBookQueue,
@Qualifier("createBookResultQueue") Destination createBookResultQueue,
PdfBookMasterRepository pdfBookMasterRepository,
BookRepository bookRepository){
String tempFilePathBaseDir = environment.getProperty("bookService.storeBookPageByPage.tempFilePathBaseDir");
return IntegrationFlows.from(Jms.messageDriverChannelAdapter(connectionFactory)
.destination(createBookQueue)
.errorChannel(storeBookPageByPageErrorChannel()))
.channel(channels -> channels.executor(Executors.newScheduledThreadPool(5)))
.....
}