Is system.util.sendMessage receiver on gateway scope multithreaded?

If many sources are throwing messages to the gateway scope using system.util.sendMessage, can multiple message handlers be running in parallel threads on the receive side? Would I have to explicitly add a mutex when I wanted to serialize the handling?

It looks like they are executed on either a dedicated or shared executor but the pool size in either case is always 1, so it seems they are effectively serialized in the end.

edit: per handler, so multiple messages to the same handler are serialized, but multiple messages to multiple handlers are not.


If I have a particularly slow handler that I would like to multi-thread, what’s the sanest way to effectively spawn/fork a sub-function and allow the message handler to return to idle and get the next message?

I would recommend setting up a private thread pool (see my for an example). But you can use invokeAsynchronous() to give each its own thread.

1 Like