Jul 3rd, 2012, 09:43 AM
Multiple messages through socket at once
Hi, good morning here.
My question is simple. Look I'll put in context.
I'm using spring integration ip to comunicate to a server through socket. But this server returns useless messages like "Welcome User, please login:", then I have to send the login message like "LOGIN:USER,PASS". Then the server answers me a response like LINE 1 "Sending your message..." LINE 2 "RESP:0;" where zero is OK and a distinct to zero if NOK. I have to tell you that this simple response parsing was a pain in the ass due to I had to override my own TcpNetConnection (to parse the response until reach the RESP string), TcpNetClientConnectionFactory (to configure my customized TcpNetConnection and Deserializer) and Deserializer (to parse each line) to reach this kind of response. The connection factory is configured with single use FALSE, due to if I send the multiple messages with single use, each time I send one the socket is reinitialized and the LOGIN command is not recognized.
Now, with single use set as FALSE I have a problem when the server (Weblogic 10.3) where I've installed this component lost the socket connection due to some network failure (disconnected from router for example). Then when I send a message, spring integration IP throw a exception like "Failed to send and receive". I've been investigating this case and the only way to know if the connection was lost is asking for inputStream.read() equal -1 within the Deserializer, but this component doesn't have the socket initialization logic.
I've analyzed the SI code to reach my answer, but it is no configurable with just SI tags. Here I have two options:
With single use, but I have to send my multiple message in one socket connection, and do the parsing logic in just one socket connection.
Without single use, but I have to figure out how to know if the input stream responses -1 and reinitialize the socket.
Any answer I will appreciate it. Thanks
Tags for this Thread