Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSC310 Lecture 13

CSC310 Lecture 13

MQTT
(2026-11-03)

Javier Gonzalez-Sanchez PRO

October 20, 2026

Transcript

16 slides
  1. CSC 3100 Fundamentals of Software Engineering Lecture 13. MQTT Broker

    Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.phd ffi o ce: 14 -227
  2. What we already know • Cl sses nd interf ces

    de ine responsibilities • UML describes structure before implement tion • Observer noti ies interested objects • Str tegy ch nges beh vior without ch nging client • J v code should re lect the design a a a a a f a a a f a a f a a a a a a • Next: How do sep r te pplic tions communic te?
  3. Vocabulary • Broker: server th t routes published mess ges

    • Client: pplic tion th t publishes nd/or subscribes • Topic: n med mess ge ch nnel, e.g., ex mple/toRe d • P ylo d: d t sent with public tion • Subscribe: express interest in topic a a a a a a a a a a a a a a a a a a 08
  4. Eclipse Paho for Java Wh t is Eclipse P ho?

    • A set of MQTT client libr ries developed by the Eclipse Found tion. • It supports multiple l ngu ges, such s J v , Python, J v Script, etc. J v Dependency (M ven) a a a a a a a a a a a a a a <dependency> <groupId>org.eclipse.paho</groupId> <artifactId>org.eclipse.paho.client.mqttv3</artifactId> <version>1.2.5</version> </dependency>
  5. Classes Main - BROKER_URL: String - TOPICS: String[] + main(String[]):

    void Subscriber - broker: String; - topics: String[] + Subscriber(String, String[]) + run(): void + connectionLost(Throwable): void + messageArrived(String, MqttMessage): void + deliveryComplete(IMqttDeliveryToken): void Publisher - broker: String; - topics: String[] + Publisher(String, String[]) + run(): void «interface» Runnable + run(): void MqttClient + connect(); + subscribe(...) + publish(...); + disconnect() «interface» MqttCallback + connectionLost(...) + messageArrived(...); + deliveryComplete(...)
  6. Quality-of-service options • 0 – "at most once": A.K.A. "fire-and-forget."

    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.
  7. CSC 3100 Fundamentals of Software Engineering Javier Gonzalez-Sanchez, Ph.D. [email protected]

    Fall 2026 Copyright Notice. These slides are provided exclusively for educational use in CSC 3100 within the California State University system. Redistribution or use for any other purpose is prohibited without prior written permission.