JXTA provided that functionality long time ago.
https://jxta-guide.dev.java.net/
https://jxta-guide.dev.java.net/source/browse/*checkout*/jxta-guide/trunk/src/guide_v2.5/JXSE_ProgGuide_v2.5.pdf