Announcement Announcement Module
Collapse
No announcement yet.
Message headers lost with UDP channel adapters Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Message headers lost with UDP channel adapters

    Hi,

    When executing a client and a server in separate JVMs/Spring contexts, messages passed between them using UDP adapters loses header values and custom headers. Actually there's no difference in behaviour if the client and the server executes in the same JVM/context. When a message arrives at the server side it appears to be a different message with different timestamp and id. The payload is the same, though

    Is this the intention? I have searched for an explanation in the reference manual, the forums, and the internet without any result. Must have missed something...

    My assumption was that a Spring Integration messages would get transported over the network without change in the message headers. According to the goal "The framework should enforce separation of concerns between business logic and integration logic".

    Here's an excerpt from the client log:
    Code:
    2012-01-10 10:22:03,692 [main] DEBUG org.springframework.integration.ip.udp.UnicastSendingMessageHandler - Sent packet for message [Payload=foo][Headers={timestamp=1326187323692, id=b4a72eb0-9113-46fe-86ea-f20a2d58e05f, FOOHEADERNAME=FOOHEADERVALUE}]
    And from the server log:
    Code:
    2012-01-10 10:22:03,724 [UDP-Incoming-Msg-Handler] DEBUG org.springframework.integration.ip.udp.UnicastReceivingChannelAdapter - Received:[Payload=[B@105bd58][Headers={timestamp=1326187323724, id=db09ae6a-a461-4a73-bfff-dbf70c716c06, ip_address=127.0.0.1, ip_hostname=127.0.0.1}]
    Have also done a little code browsing... In .../integration/ip/udp/DatagramPacketMessageMapper.java, it's obvious that headers aren't copied to the datagram packet.

    Regards,
    beam
    Last edited by beam; Jan 10th, 2012, 05:22 AM.

  • #2
    No; only the payload is transferred. The problem is that UDP (and TCP) has no standard way of transferring headers, unlike other protocols such as JMS or HTTP.

    We do mention this in the reference guide for TCP, but I see that we don't for UDP (and it could be clearer for TCP).

    Giving that these adapters are most often used to integrate with "foreign" systems that are often not even Java, let alone SI, users are left to define their own wire protocol (payload).

    We do, however, recognize that there are cases where users wish to use these protocols to transfer an entire message, including a subset of headers, to other SI applications. We do have an open JIRA for TCP https://jira.springsource.org/browse/INT-1807 which is scheduled for 2.2.

    The issue with UDP is packet size; only relatively small messages can fit into the MTU, and the size will vary with the serialization technique chosen.

    A similar JIRA for UDP was closed due to lack of interest (https://jira.springsource.org/browse/INT-1808); we can reopen it if you wish.

    In the meantime, you could a pair of transformers to add/extract the headers you need to/from the payload.

    Comment


    • #3
      Thanks Gary.

      Yes I'm aware of the fact that UDP/TCP communication between two Spring applications is a rather specialized case.

      Originally posted by Gary Russell View Post
      A similar JIRA for UDP was closed due to lack of interest (https://jira.springsource.org/browse/INT-1808); we can reopen it if you wish.
      Please don't. There are surely more important issues than this.

      Originally posted by Gary Russell View Post
      In the meantime, you could a pair of transformers to add/extract the headers you need to/from the payload.
      Yeah, did that... with really bad code... but it was a quick win... no way near good enough to publish... <<blushing>>

      Regards,
      beam

      Comment

      Working...
      X