Search code examples
javaspring-bootrestspring-mvcsequential

Spring Direct Channel - multiple send message at the same time


I know some basics about Spring Integration channels as there are two types of channel as SubscribableChannel channel and Pollable channel and out of it, Directchannel is one of the type of Subscribablechannel. I have a scenario, where I can send the continuous message to direct channel after every 2 millisecond, but at consumer end i.e. (I am using service activator) it can take 1 second to process after receiving the message. on the basis of implementation I am returning the failure or success response to caller. the requirement here is that I must need to process them sequentially, i.e. I cannot execute it in a synchronous way. I have the following questions as,

  1. From web resources I read that, direct channel can block the sender, but I did not get clearly in which case ?
  2. can I make use of direct channel to send the continuous message after every 2-3 milliseconds, and if service activator returning the response, to whom it returns ? Is it to caller thread of DirectChannel? (Also I want those messages to be get executed sequentially, that's why I am choosing Direct channel)
  3. if DirectChannel won't fit in above scenario, then which SubscribableChannel channel I can make use of?

I am describing my scenario one more time,

My application receiving REST request after every 2 or 3 millisecond, and I want to return success or failure to the caller on the basis of process execution. here the one more things is that, I cannot execute the above request asynchronously, I want to execute them sequentially only. So I decided to send those request to DirectChannel.

please suggest any good way to tackle it ?


Solution

  • I used multiple Executor channel which can be configured with the thread executor, so I used single thread only for the Executor channel and provided a some capacity for blocking queue.