Reputation: 113
I need suggestion how to implement, if it is possible, with the Spring integration the following TCP flow:
In groovy the code could be demonstrated as follow:
def serverSocket = new ServerSocket(...)
def connSocket = serverSocket.accept()
connSocket.outputStream.write(...)
while(true) {
def readBuffer = new byte[256]
connSocket.inputStream.read(readBuffer)
if(needToSendBack(readBuffer)) {
connSocket.outputStream.write(...)
}
}
def sendByDemand(def data) {
connSocket.outputStream.write(data)
}
The method sendByDemand could be invoked from the separate thread.
Here is a list of problems which I marked for myself, which prevents me to implement it with the Spring Integration (2.x version):
If someone could post possible Spring configuration for this scenario or point to the similar flow example it may be very helpful.
Upvotes: 0
Views: 199
Reputation: 174739
Your use case is possible, but it would make your life easier if you could upgrade to 3.0.
'Dispatcher has no subscribers' means there is no consumer subscribed to that channel.
You need to show your configuration; you must use collaborating channel adapters for this (not a gateway).
You need to capture the connectionId
of the connection when it is established, and use it to populate the ip_connectionId
header so the outbound channel adapter knows which socket to which to write the message.
Upvotes: 0