0

I want to use Spring Integration for HTTP inbound message processing.

I know, that it spring integration channel would run on a container thread, but if I want to use splits, what threads would be used?

How the result of split would be returned to the initial web request thread?

MaSEL
  • 505
  • 1
  • 5
  • 20

1 Answers1

2

(Note: I am not 100% sure if I understand you use case, but as a general remark:)

The spring integration spitter splits a message in multiple "smaller" messages. This is unrelated to multi-threading, that is, it does not per-se imply that the smaller messages are processed in parallel. It is still a sequential stream of smaller messages.

You can then process the smaller messages in parallel, by defining a handler with a given parallelism and you can define that this handler uses a dedicated thread pool.

(Sorry if this does not answer your question, please clarify).

Christian Fries
  • 16,175
  • 10
  • 56
  • 67
  • I think, you got it right. For instance, I've splitted the messages to the smaller ones. Then I want to process each of them in parallel (like parsing the message and sending the HTTP request to external web service) . I create channel with executor with fixed thread pool and forward the messages there. Would the initial thread wait for them? How I would get the result? – MaSEL May 21 '20 at 10:04
  • Yes, this is how I see it. And all the messages coming from the different container threads will be processed in the fixed thread pool. The container threads are there to keep the HTTP responsive; the fixed thread pool will work on the messages; the queue in-between acts like a buffer. – Christian Fries May 21 '20 at 10:07
  • And once all thread pool threads will be done with the messages, the processing would back to the container thread? Should I define this behavior somehow explicitly? – MaSEL May 21 '20 at 10:15
  • 2
    If you want to suspend the web container thread; you will need to use a messaging gaeway and aggregate the results and return them to the gateway. The gateway can be configured with a timeout. – Gary Russell May 21 '20 at 14:24