I know spring integration has TcpInboundGateway, TcpOutboundGateway and ByteArrayStxEtxSerializer to handle data coming through TCP port.
ByteArrayStxEtxSerializer works great if the TCP server needs to read all the data sent from the client and then processes it. (request and response model) I am using single-use=false so that multiple requests can be processed in the same connection.
For example if the client sends 0x02AAPL0x03 then Server can send the AAPL price.
My TCP Server is working if the client sends 0x02AAPL0x030x02GOOG0x03. It sends the price of AAPL and GOOG price.
If there is invalid ticker, TCP server should ignore it and give the price of the valid tickers.
When the client sends 0x02AAPL0x030x2INVALIDTICKER0x030x02GOOG0x03, My client receives the AAPL price and waits for ever and times out.
My TCP Server uses ServiceActivator and returns null for INVALIDTICKER.
I am wondering why the client does not receive the valid prices. is the socket outputStream blocked? is there any setting which allows to skip some responses from the ServiceActivator?
Please help.
we are using spring integration 4.2.6.RELEASE version and java 8.
Here is my spring configuration:
<bean id="connectionSerializeDeserialize" class="org.springframework.integration.ip.tcp.serializer.ByteArrayStxEtxSerializer"/>
<int-ip:tcp-inbound-gateway id="gatewayCrLf"
connection-factory="crLfServer"
request-channel="serverBytes2StringChannel"
error-channel="errorChannel"
reply-timeout="10000"/> <!-- reply-timeout works on inbound-gateway -->
<int:channel id="toSA" />
<int:service-activator input-channel="toSA"
ref="myService"
method="prepare"/>
<int:object-to-string-transformer id="serverBytes2String"
input-channel="serverBytes2StringChannel"
output-channel="toSA"/>
<int:transformer id="errorHandler"
input-channel="errorChannel"
expression="payload.failedMessage.payload + ':' + payload.cause.message"/>
Thank you