I am building an enterprise application and i am using active mq for internal communication between applications. When i use task executor with my poller AbstractPollingEndpoint and ErrorHandlingTaskExecutor object instances causes memory leak. Object counts in the heap increases even if the application is in idle mode. When i close this part of the code
.taskExecutor(outTaskExecutor)
the problem doesnot occur anymore. But we are preparing for a heavy traffic and we need no provide more threads in order to handle messages. What am i doing wrong? Can you help please?
Thank you
Executor Service outTaskExecutor = Executors.newFixedThreadPool(10);
IntegrationFlow jmsOutbound = IntegrationFlows.from(jmsInChannel)
.handle(Jms.outboundAdapter(this.jmsTemplate.getConnectionFactory())
.destinationExpression("headers['responseQueueName']")
, s -> s.poller(p -> p.fixedDelay(pollerDelay).taskExecutor(outTaskExecutor)).get())
.get();
this.flowContext.registration(jmsOutbound).id("jmsOutbound").register();
It doesn't look right to have Executor Service outTaskExecutor = Executors.newFixedThreadPool(10);
for every single dynamic flow. Why just don't have it as a singleton and share it with all your dynamic flows?
Also pay attention to this description of similar issue in docs: https://docs.spring.io/spring-integration/reference/html/#async-polling
Plus this SO question: Memory leak because of receive timeout and task executor out of tune conf