a tion mech a nism for exch a nging d a t a between two systems. • - How: Utilizes TCP/UDP protocols for reli a ble/unreli a ble d a t a tr a nsfer. • - Use C a se: Direct communic a tion between client-server a pplic a tions (e.g., f ile tr a nsfer a nd ch a t). WebSockets • - Wh a t: Full-duplex communic a tion protocol over a single TCP connection. • - How: En a bles persistent, bidirection a l communic a tion between client a nd server in re a l- time. • - Use C a se: Re a l-time a pplic a tions like live ch a ts, g a ming, a nd stock tr a ding pl a tforms. MQTT (Mess a ge Queuing Telemetry Tr a nsport) • Wh a t: Lightweight mess a ging protocol designed for low-b a ndwidth, high-l a tency networks. • How: Uses a publish-subscribe p a ttern for e ff icient communic a tion between devices. • Use C a se: Ide a l for IoT a pplic a tions, sm a rt home devices, a nd sensor networks. 12
ge Queuing Telemetry Tr a nsport) is a lightweight, publish-subscribe network protocol. • Designed for constr a ined devices a nd low-b a ndwidth, high-l a tency, or unreli a ble networks. Key Fe a tures • Simple a nd e a sy to implement. • Low b a ndwidth consumption. • Reli a ble mess a ge delivery. • Sc a l a ble to millions of devices. 23
a t h a ndles mess a ge distribution. • Ex a mples: Mosquitto, HiveMQ, EMQX, AWS MQ. Clients • Devices or a pplic a tions th a t publish (send) a nd subscribe (receive) mess a ges. • Ex a mples: Sensors, mobile a pps, a nd IoT devices. Topics • Hier a rchic a l n a mesp a ces for org a nizing mess a ges. • Ex a mple: home/livingRoom/temper a ture. 24
broker. Subscribe • Clients subscribe to topics of interest. Publish • Clients publish mess a ges to topics. Receive • Clients receive mess a ges from topics they a re subscribed to. Disconnect • Clients disconnect from the broker. 25
a ho? • A set of MQTT client libr a ries developed by the Eclipse Found a tion. • It supports multiple l a ngu a ges, such a s J a v a , Python, J a v a Script, etc. J a v a Dependency (M a ven) <dependency> <groupId>org.eclipse.paho</groupId> <artifactId>org.eclipse.paho.client.mqttv3</artifactId> <version>1.2.5</version> </dependency> 26
This option is suitable when message loss is acceptable, as it doesn't require acknowledgment or persistence. • 1 – "at least once": This option should be chosen when message loss is unacceptable, and your subscribers can handle duplicate messages. • 2 – "Exactly once": This option is ideal when message loss is unacceptable, and your subscribers cannot handle duplicate messages. 28
IoT and other use cases. • Mosquitto: A popular open-source MQTT broker. • Eclipse Paho: A versatile MQTT client library. • Java Example: https://github.com/CSC3100/MQTT 30