Announcement Announcement Module
No announcement yet.
Sending messages to TCP clients that are not always connected Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sending messages to TCP clients that are not always connected

    I have a requirement that I need to send a message to a TCP client that connects to the SI server periodically say via tcp inbound gateway. There is no way for the SI server to initiate a connection to the device. I would like to place a message onto a channel via a simple gateway and have this message routed to the device when it connects. Until the device connects to the server the message should remain in the system. Each message will be for a particular device and the device is known by a device ID which the device sends to the server when it connects.

    Is there a way to publish a message destined for a particular device even if that device is not connected?

  • #2
    I was initially thinking you wanted the client to connect and we publish an application event as a result of the connection. We don't currently support that, but it wouldn't be too difficult to do that. Open a JIRA if you wish.

    However, you then went on to say that the "...client sends it's ID when it connects...".

    Can't you use the reception of that message as a stimulus for the event? Simply capture the ip_connection_id header from that message and insert it into any message(s) you wish to send.

    Use collaborating channel adapters rather than a gateway (receive the ID on an inbound adapter and send the message(s) to the oubound adapter, after enriching the header with the connection id.
    Last edited by Gary Russell; Jan 18th, 2012, 11:18 AM.


    • #3
      Thanks Gary,

      Clarifying the requirement further - From the point of view of a client wanting to send a message to the device, the message can be sent at any time but will only be delivered to the device when the device connects. One way I can think of handling this is to accept the message via a gateway and then store message in a database keyed by deviceID. When the device connects I could raise an integration event which would include the deviceID and ip_connection_id. On receipt of the event I could initiate a service activator or jdbc inbound channel adapter to read the message for the particular deviceId and send it to the ip_connection_id via an outbound TCP channel adapter.


      • #4
        Or, you can use an <aggregator/> backed by a message store, with a custom release strategy that releases the group when the client connect message comes in. That will work whether there's one or more pending messages for a device.

        The SI message store will take care of persistence for you.


        • #5
          Now that's the kind of solution I was after. I'll give that a try

          Thanks Gary