0
votes

I have a system which accepts data from multiple sources. The client(a third party client which I have no control) handles all the data source in a thread pool. I can register callbacks and the callback will be triggered from different threads. I am using gateway to send data to separate channels. After processing each channel, I wanted to transform each to a message on to a single channel. This is because most of the processing are same for the data coming from different sources. Following is a sample xml

<gateway default-request-channel="a" />
<channel id='a'/> 
<gateway default-request-channel="b" />
<channel id='b'/> 
<!-- inputs to a and b can be from different threads -->
<channel id='c' />

<transformer input-channel="a" output-channel="c" />
<transformer input-channel="b" output-channel="c" />

<outbound-channel-adapter channel="c" />

When the two transformers output to the same channel, will there be any concurrency issues as transformers are operating on different threads? Is it possible to have only one thread handling channel 'c'? Otherwise, what is the recommended practice in handling multiple threads in the same channel?

1

1 Answers

-1
votes

There are no such concurrency issues in the framework - however, your code (invoked by service activators etc) must be thread-safe.

If the outbound channel adapter invokes your POJO, it must be thread safe. If it's a framework adapter (e.g. http etc), it is thread safe.

If you can't make your code thread safe, you can use an Executor Channel for channel c (config here) with a single thread task executor to run the flow on a single thread.