Class DatagramPacketMessageMapper

All Implemented Interfaces:
Aware, BeanFactoryAware, InboundMessageMapper<DatagramPacket>, OutboundMessageMapper<DatagramPacket>

public class DatagramPacketMessageMapper
extends Object
implements InboundMessageMapper<DatagramPacket>, OutboundMessageMapper<DatagramPacket>, BeanFactoryAware
Message Mapper for converting to and from UDP DatagramPackets. When converting to a Message, the payload will be a byte array containing the data from the received packet. When converting from a Message, the payload may be either a byte array or a String. The default charset for converting a String to a byte array is UTF-8, but that may be changed by invoking the setCharset(String) method. By default, the UDP messages will be unreliable (truncation may occur on the receiving end; packets may be lost). Reliability can be enhanced by one or both of the following techniques:
  • including a binary message length at the beginning of the packet
  • requesting a receipt acknowledgment
Mark Fisher, Gary Russell, Dave Syer, Artem Bilan