Here is my problem:
I've implemented a socket server like this (using spring integration):
So each incoming tcp call is handle by a different thread from the 'socketExecutor' thread pool.Code:<task:executor id="socketExecutor" pool-size="${integration.socket.pool.max.size}"/> <ip:tcp-connection-factory id="server" type="server" port="${integration.server.port}" using-nio="${integration.server.using-nio}" single-use="${integration.server.single-use}" so-timeout="${integration.server.so-timeout}" deserializer="deserializer" task-executor="socketExecutor" so-linger="${integration.server.so-linger}" so-send-buffer-size="${integration.server.so-send-buffer}" so-receive-buffer-size="${integration.server.so-receive-buffer}" /> <ip:tcp-inbound-channel-adapter channel="tcpInputChannel" connection-factory="server" error-channel="errorChannel"/> <ip:tcp-outbound-channel-adapter channel="tcpOutpuChannel" connection-factory="server" />
It reads the socket and sends the input to the splitter/aggregator for further processing:
Here the intended flow (it's all direct channel, so it's like one big transaction)Code:<task:executor id="asmTxExecutor" pool-size= "${integration.asmv.pool.max.size}" /> <channel id="parallelTxChannel"> <dispatcher task-executor="asmTxExecutor" /> </channel> <chain input-channel="tcpInputChannel" output-hannel="parallelTxChannel"> <splitter ref="splitter" /> </chain> <chain input-channel="parallelTxChannel" output-channel= "tcpOutpuChannel"> <service-activator ref="transactionExecutorService" /> <aggregator ref="aggregator" /> </chain>
The input gets split (multi-thread processing) then aggregated and reply.
The problem is once the input message reaches the splitter and the multi-threading starts, my tcp server loses focus and think there is a new connection and tries to read (actually re-read), but blocks, until the multi-processing is completed and replied onto the output-channel. With this action, the socket is closed and the extra 'blocked' read then throws a SocketException.
Is it clear?
Is there a way to prevent this extra read from happening?
It's seems like the uses of 2 different thread pool is causing this problem.
The extra read is eliminated when no second thread pool is used, eliminating the multi-threaded processing at the same time.


Reply With Quote
