I'm new to Spring Integration and currently trying to receive data from some devices over TCP. I've come up with the following Spring context:
<bean id="serializer" class="com.somepackage.CustomSerializer"/>
<int-ip:tcp-connection-factory id="connectionFactory"
type="server"
port="${tcp.socket.connection.listener.port}"
deserializer="serializer" />
The problem with a device's protocol is that upon initial connection it sends a handshaking sequence and expects a magic answer before it starts sending the messages.
A message pattern is different from the handshaking sequence, I cannot implement a serializer that distinguish between these two. If I could I would implement this handshaking process as an interceptor. So I tried to implement a statefull serializer but it turned out that serializers are singletons, shared between different connections.
Could you please advise how to perform some custom negotiation (handshaking) before default mechanisms (splitting data into messages) come into play ? Should I customize a connection factory ?
Thank you !
I think you need a custom TCP Interceptor. From the documentation: