I have a TCP inbound endpoint which references a TCP connector. This is a request-response endpoint. The TCP Client is a 3rd party application which sends requests on only one socket. This is how I have set up my TCP endpoint. Endpoint:
<tcp:inbound-endpoint exchange-pattern="request-response"
responseTimeout="10000" doc:name="TCP" address="${Endpoint}" encoding="ISO-8859-1" connector-ref="TCP"/>
Connector:
<tcp:connector name="TCP" doc:name="TCP connector"
clientSoTimeout="${Client_SO_Timeout}" receiveBacklog="0" receiveBufferSize="0"
sendBufferSize="0" serverSoTimeout="${Server_SO_Timeout}" socketSoLinger="0"
validateConnections="true" keepAlive="true" sendTcpNoDelay="true">
<receiver-threading-profile maxThreadsActive="${TCP_MaxThreadsActive}" maxThreadsIdle = "${TCP_MaxThreadsIdle}" />
<reconnect-forever />
<service-overrides messageReceiver="CustomMessageReceiver" />
<tcp:custom-protocol ref="CustomLengthProtocol" />
</tcp:connector>
The flow is working fine. But when concurrent requests have to be processed, the last few requests are timing out. What I understand from this is that the messages are waiting at the receiver to be processed (since only one TCP session is used) until the previous request is completed by the mule flow.
In order to tune this, I am looking for a way to change the mule flow as below: After receiving the requests from the client, I need to send it to the mule-flow which may process it asynchronously and push the response to the same socket. Once the request is received at the endpoint, it does not need to wait for the previous request's flow to complete before processing the next request. There is no requirement to keep the sequence of request/responses from the mule flow. Is there a way to achieve this by extending the mule TCP endpoint functionality? This is similar to the Queued Asynchronous Flow processing strategy, except that the response has to be sent back to the original TCP socket.