I am designing a gateway/client application to the 3rd party system which provides a TCP/IP service as the interface to communicate with it. So basically I need to listen on a queue [i.e wait for new messages] , get a message from the queue, transform the message , send the message to the TCP server (not in control - third party), get response from the server and then transform the message and send it back to another queue. The bit from getting a message from the queue to the end (i.e sending to another queue) should belong to one transaction. and each request can wait for the previous requests response returns. The interactions with the queues (i.e receive and send) i have implemented using spring-jms and spring transaction support (we are quite confident we will not move from jms based transports to other transports). remaining is the interface to TCP service for which i am hoping to use spring integration.
The TCP server is a request /response one, basically if we send a request, it will reply - and i know the message delimiters.
I have taken the "tcp-client-server" example from the spring-integration-samples as a template to write a gateway for the TCP service - i have commented out the TCP server related configs from the sample. The tricky thing to handle is the fact that the TCP server can send unsolicited messages as well. So basically after the first request to the server, the server can send messages which are not relevant to the request as well, but we will eventually get the expected response as well - which will be identified using a sequence number within the message content - i.e the response messages sequence number will be the same as the request messages sequence number. Also we know a way of identifying the unsolicited messages by looking at the message content. now the question is how we can filter these unsolicited trafic from the response.
so basically in the following
we need a way of filtering any messages which are unsolicited (possibly sending them to a log file) and then continue to listen for the correct message and then push it to the reply channel. the request can wait until this happens.Code:<ip:tcp-outbound-gateway id="outGateway" request-channel="input" reply-channel="clientBytes2StringChannel" connection-factory="client" request-timeout="10000" reply-timeout="10000" />
any ideas on how i can do this?
Thanks in advance for any replies.