javascript
java集成spring,Spring集成
為了提高性能,我建議使用帶有任務(wù) Actuator 的executorchannel來(lái)控制線程池大小的數(shù)量 . 通過(guò)這種方式,您可以獲得消息到達(dá)jms隊(duì)列時(shí)消費(fèi)者接收消息并在單獨(dú)的線程中處理流的情況 . 請(qǐng)記住,在這種配置中,多線程工作由taskexecutor通道執(zhí)行taht將在單獨(dú)的線程中執(zhí)行消息的重新生成,因此您已經(jīng)想到了您想要的多線程等級(jí) .
對(duì)于隊(duì)列消息通道,確實(shí)需要輪詢器在通道上輪詢以執(zhí)行recive,隊(duì)列容量是幕后原子隊(duì)列的容量 .
您可以在xml中以這種方式配置執(zhí)行程序通道
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)))
.....
}
總結(jié)
以上是生活随笔為你收集整理的java集成spring,Spring集成的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 信号处理:谱密度
- 下一篇: gradle idea java ssm