我正在根据数据库中的数据创建动态集成流。我们需要使用文件名模式轮询的目录在数据库中例如Instance, directory , filename ABC , c:/input1 , test.txtDEF , d:/input2 , fresh.xlsx我有大约 200-300 个条目,所以我正在为每条记录创建集成流,因为它将有不同的处理器等对于每条记录 IntegrationFlowBuilder flowBuilder = IntegrationFlows .from(new CustomFileReadingSource(input), consumer); flowBuilder.transform(new ObjectToJsonTransformer()); flowBuilder.handle(o -> { // System.out.println(o.getPayload()); });context.registration(flowBuilder.get()).register();一旦所有这些都注册了,但是当我查看 VisualVM 或日志时,我只看到 8-10 个线程,而不是 100 或 200 个。从日志2018-11-13 16:00:41.399 [task-scheduler-3] INFO c.b.m.p.f.b.LoggerSourceAdvisor.afterReceive(32) 2018-11-13 16:00:41.587 [task-scheduler-10] INFO c.b.m.p.f.b.LoggerSourceAdvisor.afterReceive(32)2018-11-13 16:00:41.807 [task-scheduler-4] INFO c.b.m.p.f.b.LoggerSourceAdvisor.afterReceive(32) 2018-11-13 16:00:42.071 [task-scheduler-5] INFO c.b.m.p.f.b.LoggerSourceAdvisor.afterReceive(32) 2018-11-13 16:00:42.323 [task-scheduler-7] INFO c.b.m.p.f.b.LoggerSourceAdvisor.afterReceive(32) 2018-11-13 16:00:42.569 [task-scheduler-6] INFO c.b.m.p.f.b.LoggerSourceAdvisor.afterReceive(32) 2018-11-13 16:00:42.878 [task-scheduler-8] INFO c.b.m.p.f.b.LoggerSourceAdvisor.afterReceive(32) 2018-11-13 16:00:43.197 [task-scheduler-9] INFO c.b.m.p.f.b.LoggerSourceAdvisor.afterReceive(32) 2018-11-13 16:00:43.588 [task-scheduler-1] INFO c.b.m.p.f.b.LoggerSourceAdvisor.afterReceive(32) 2018-11-13 16:00:43.951 [task-scheduler-2] INFO c.b.m.p.f.b.LoggerSourceAdvisor.afterReceive(32) 如您所见,它只有少数线程轮询线程有人可以帮助为什么它不创建线程或任何更好的方法来实现并行轮询器吗?
2 回答
慕雪6442864
TA贡献1812条经验 获得超5个赞
这是正确的。因为所有Polling Ednpoints
都基于预定义的全局ThreadPoolTaskScheduler
,10
默认为池大小:https ://docs.spring.io/spring-integration/docs/5.1.0.RELEASE/reference/html/configuration.html#namespace-taskscheduler
另一方面,尝试拥有 100 个线程同时您的 CPU 最多为 16 个内核是毫无意义的。创建更多线程甚至可能导致应用程序变慢。
添加回答
举报
0/150
提交
取消