In one of my projects I needed to use udp multicast messaging to distribute notifications. I’ve found numerous articles about multicasting but these were mostly oriented towards an explanation of the technology with just simple code snippets demonstrating basic api calls.
My aim was to build a component which would provide reliable encapsulation of network interactions and that would expose multicast functionality to upper layers through publish/subscribe implementation of the observer pattern.
Requirements for message broker component:
- distribute string messages to anyone interested (observer pattern) using udp multicasting
- single component encapsulating both send & receive logic
- no machine specific configuration
- basic error detection
- thread-safe interaction
- detection of duplicate messages
- ability to handle fragmented data
- ability to recover from data received in unexpected format (e.g. network errors, interrupted transmission, etc.)