java集成spring,Spring集成

为了提高性能,我建议使用带有任务 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)))

.....

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值