Spring Integration - Simultaneous Service Activators

I have a queue channel and a service activator with poller that reads from this queue. I would like to have a configuration to say "I want 50 threads to poll this queue, and every time you poll and get a message back, call the service that the service activator points to in this thread."

The service does not have @Async annotations, but without attacks and is safe to run simultaneously.

Would it do it below? Are there other preferred ways to achieve this?

 <int:channel id="titles"> <int:queue/> </int:channel> <int:service-activator output-channel="resolvedIds" ref="searchService" method="searchOnTitle" input-channel="titles"> <int:poller fixed-delay="100" time-unit="MILLISECONDS" task-executor="taskExecutor"></int:poller> </int:service-activator> <task:executor id="taskExecutor" pool-size="50" keep-alive="120" /> 
+7
source share
1 answer

Yes, I think he does what you want. When you enter QueueChannel, the interaction becomes asynchronous - you do not need @Async. If you did not configure the box using poller, it will use the default poller.

What you have outlined is the best way to achieve it. You can also consider setting a limit on the size of the queue - so if there is a lag in working with the manufacturer, this will not lead to a lack of memory. If the size is set, then send calls to the channel are blocked - they act as a choke.

Your configuration will work as you expect. The only problem is that, once you start creating performers and pollinators for each endpoint, it becomes difficult to determine the optimal configuration for the entire application. It's okay to do this kind of optimization for a few specific steps - but not for all endpoints (nothing in your questions suggests that you are doing this, just thought I would raise it anyway.

+8
source

All Articles