Announcement Announcement Module
Collapse
No announcement yet.
Socket Inbound Listener Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Socket Inbound Listener

    I am in the process of implementing a basic socket listener service. This listener will accept connections on a server socket, read a message from the InputStream of the 'accept' socket, process the message through a series of channels, and eventually write a response to the OutputStream of the same socket. Content of the channels aside, this will behave more or less like a echo server.

    I am considering several approaches and would appreciate any feedback.

    Option 1) Implement listener as a standalone component (i.e. not associated with a channel). The listener would read the incoming message and then pass it through a gateway. The response would eventually be returned through the gateway. The integration layer would deal only with Strings and/or byte[]'s and have no direct relationship with the socket.

    Option 2) Leverage the socket support which is planned for 2.0: http://forum.springsource.org/showthread.php?t=80814. I looked through the code on trunk for this and I see how it would be used to either send or receive messages. However, I don't see a clear way to return a response to any of the various implementations of AbstractInternetProtocolReceivingChannelAdapter. Am I missing something, or does this fall outside the intended usage?

    Option 3) Provide a method in the listener to use as the MessageSource of SourcePollingChannel (i.e. <inbound-channel-adapter>), and provide a separate method which would be invoked by a <service-activator> to send the reply back to the original socket. Since the listener will handle multiple connections, a Map or something similar would be used to ensure that the response is sent to the correct socket. This seems rather messy, and might just indicate that I am missing something in option 2.

    From here, option 1 seems like the most straightforward way to accomplish this.

    Thanks!

  • #2
    It sounds like you are asking for a TCP "gateway". This is something that I was just discussing a few days ago with Gary Russell, the main developer for the TCP/UDP adapters.

    I just created the following issue: http://jira.springframework.org/browse/INT-1008

    Please feel free to vote on it, add a watch, and most importantly to provide comments and feedback once it's rolling.

    Thanks,
    Mark

    Comment


    • #3
      Mark
      i was looking for the same functionality of having some sort of gateway for handling asynchronous IO operations.
      After reading threads and googling, i was redirected to JIRA INT-1008. I guess latest code is in trunk.
      However, could you kindly explain me how will it work?
      Let's say, i have implemented a ServerSocket using NIO classes that listens for requests, processes them and then reply back to the Client.
      I read from JIRA that you guys have implemented a SimpleTcpNetInboundGateway and SimpleTcpNetOutboundGateway.
      As i m littlebit lost on this..(and again i m confused on Outbound/Inbound things), could you explain me a simlpe usecase?

      Will TCP clients send messages to OutboundGateway channel, and read messages from InboundGatewayChannel?

      w/kindest regards
      marco

      Comment

      Working...
      X