I am trying to setup my application using spring integration, being a newbie, need advice on below use case -
There is queue where messages from another application are getting pushed. My application consume messages from the queue, does some data massaging and then push it to another outbound queue. Goal is, to process messages in a concurrent way.
As per my understanding we can have 2 approaches-
1- Using #Poller
<int:service-activator ref="messageProcessor" method="process" input-channel="incomingChannel">
<int:poller fixed-rate="100" task-executor="executor" />
<int:service-activator/>
<task:executor id="executor" pool-size="10"/>
2- Using #Dispatcher
<int:channel id="incomingChannel">
<int:dispatcher task-executor="executor"/>
</int:channel>
<int:service-activator ref="messageProcessor" method="process" input-channel="incomingChannel" />
<task:executor id="executor" pool-size="10"/>
Looking at the poller based configuration it seems that, there will be multiple threads available in the pool, fetching messages and processing it concurrently. Concern here is-
i) Poller will keep running in the background unnecessarily (resource hit).
ii) Even if messages are there on the channel, will be wasting milliseconds based on the fixed-rate (as poller will fetch messages after every 100 seconds).
Dispatcher based configuration seems to be message driven and may be perfect for my use case. Correct me if I am wrong, In this case threads are only responsible for dispatching the message to a subscriber.
If that is the case-
Do I need to have multiple service activators associated with the channel ?
Is there any way to attach multiple instances of same service activator config dynamically?
Suggest me what is best approach to deal with this. Thanks.