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

CSC510 Lecture 19

CSC510 Lecture 19

Connecting the Dots
(20261019)

Avatar for Javier Gonzalez-Sanchez

Javier Gonzalez-Sanchez PRO

October 20, 2026

Transcript

  1. CSC 5100 Modern Software Engineering Lecture 19. Connecting the Dots

    (in the Cloud) Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.phd ffi o ce: 14 -227
  2. Assignment 04 • Extend your exis ng Java AWS Lambda

    into a complete cloud integra on. • One result → persistent storage → asynchronous events → desktop subscriber. ti fi 7 ti • Seven Tasks, one nal Pull Request.
  3. Goal Every assigned Lambda supports POST to compute, store, and

    publish. Every assigned Lambda supports GET to retrieve a stored result by UUID. A Java desktop application subscribes to MQTT and publishes an ACK. Keep your original computation and input contract working. 9
  4. Tasks 1. REST contract and UUID lookup (GET + POST).

    2. DynamoDB 3. S3 4. SNS 5. SQS. 6. Java MQTT subscriber, ACK, and tests. 7. End-to-end evidence and one final PR. 10
  5. To Do Move each Task: To Do → In Progress

    → Done as work advances. Close each native sub-issue (TASK) only when its criteria are met. After all seven Tasks are closed, submit ONE PR. Title: A04 - <LambdaName> | Body: A04 Story: #<parent> 11
  6. My working example | TemperatureLambda POST: compute, generate UUID, save

    and publish. GET with ?id=<uuid>: retrieve a previously stored result. We will use the same pattern for your assigned Lambda. 13
  7. Review | What each AWS service does API Gateway —

    receives HTTP and routes to Lambda. Lambda — executes your Java computation. DynamoDB — stores structured results by UUID. S3 — stores a JSON object; SNS — publishes a notification. SQS — holds a message until a consumer processes it. 15
  8. Review | Storage and Messaging DynamoDB table: csc5100-results (id is

    a String UUID). S3 bucket: csc5100-results; use your assigned prefix. SNS topic: csc5100-events. SQS queue: csc5100-processing. 16
  9. Reference code | TemperatureLambda // Simplified from instructor/TemperatureLambda.java String id

    = UUID.randomUUID().toString(); output.put("id", id); storage.save(id, mapper.writeValueAsString(output)); messaging.publish(mapper.writeValueAsString(output)); return httpResponse(200, mapper.writeValueAsString(output)); // GET ?id=... uses storage.get(id) 17
  10. Reference code: storage adapter // TemperatureStorage.java — simplified s3.putObject(PutObjectRequest.builder() .bucket(bucket).key("instructor/temperature/"

    + id + ".json") .build(), RequestBody.fromString(json)); dynamo.putItem(PutItemRequest.builder().tableName(table) .item(Map.of("id", AttributeValue.fromS(id), "resultJson", AttributeValue.fromS(json))) .build()); 18
  11. Event contract { "id": "14caa8ee-ca63-41f4-b57f-074007b2affc", "operation": "GazeClusterLambda", "result": 2 }

    // SQS → instructor EventProcessorLambda → csc5100/events/gaze-clusters 21
  12. Final submission — one PR PR title: A04 - GazeClusterLambda

    PR body must include: A04 Story: #272 Evidence: curl, JUnit, (DynamoDB, S3, SNS, SQS, AWS IoT Core, HiveMQ, desktop receipt, ACK)... All seven native sub-issues closed before final PR. 22
  13. Question 1 — Can any language call our API? Yes.

    HTTP + JSON is a language-independent contract. Java, Python, JavaScript, curl, or an AI tool can call the same URL. POST computes and publishes; GET retrieves a saved result by UUID. The client language does not change the backend. 24
  14. REST from Java HttpClient client = HttpClient.newHttpClient(); HttpRequest request =

    HttpRequest.newBuilder() .uri( URI.create( "https://api.javiergs.phd/5100/temperature"+ "?value=86&from=F&to=C") ) .GET() .build(); String json = client .send(request, HttpResponse.BodyHandlers.ofString()) .body(); System.out.println(json); 25
  15. REST from Python import requests url = "https://api.javiergs.phd/5100/temperature" r =

    requests.get( url, params={"value": 86, "from": "F", "to": "C"} ) print(r.json()) # POST uses requests.post(url, json={...}) 26
  16. REST from JavaScript const url = "https://api.javiergs.phd/5100/temperature"; const response =

    await fetch(url + "?value=86&from=F&to=C"); console.log(await response.json()); // POST: fetch(url, { method: "POST", // headers: {"Content-Type":"application/json"}, // body: JSON.stringify(input) }); // In a browser, the server must allow CORS (Cross-Origin Resource Sharing). 27
  17. Our Lambda endpoints — 1 of 2 TemperatureLambda → /5100/temperature

    DominantAffectLambda → /5100/dominant-affect RobotDistanceLambda → /5100/robot-distance RobotReachabilityLambda → /5100/robot-reachability LidarClosestLambda → /5100/lidar-closest LidarSafetyLambda → /5100/lidar-safety DataFreshnessLambda → /5100/data-freshness 28
  18. Our Lambda endpoints — 2 of 2 CoordinateNormalizerLambda → /5100/coordinate-normalizer

    EventRateLambda → /5100/event-rate GazeClusterLambda → /5100/gaze-clusters EncryptMessageLambda → /5100/encrypt NearestSampleLambda → /5100/nearest-sample MovingAverageLambda → /5100/moving-average A04 target: GET + POST for every assigned Lambda. 29
  19. Question 2 — Can any language subscribe? Yes. MQTT is

    a protocol, not a Java-only library. One published event can reach many connected subscribers. Java: Eclipse Paho • Python: Paho MQTT • JS: MQTT.js. 31
  20. MQTT topics and the # wildcard Subscribe to: csc5100/events/# Matches:

    csc5100/events/temperature Matches: csc5100/events/robot-distance Matches: csc5100/events/gaze-clusters It receives new matching publications, NOT all historical results. REST GET by UUID is for retrieving saved results. 32
  21. MQTT subscriber — Java (Paho) MqttClient client = new MqttClient(

    "tcp://broker.hivemq.com:1883",MqttClient.generateClientId()); client.connect(); client.subscribe("csc5100/events/#", (topic, msg) -> { System.out.println(topic + " " + new String(msg.getPayload(), java.nio.charset.StandardCharsets.UTF_8)); }); // A04 also requires publishing an ACK for your UUID. 33
  22. MQTT subscriber — Python (Paho) import paho.mqtt.client as mqtt def

    on_message(client, userdata, msg): print(msg.topic, msg.payload.decode()) client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2) client.on_message = on_message client.connect("broker.hivemq.com", 1883) client.subscribe("csc5100/events/#") client.loop_forever() 34
  23. MQTT subscriber — JavaScript (MQTT.js) // Load MQTT.js (library) in

    a browser page first. // <head> // <script src="https://unpkg.com/mqtt/dist/mqtt.min.js"></script> // </head> const client = mqtt.connect("wss://broker.hivemq.com:8884/mqtt"); client.on("connect", () => { client.subscribe("csc5100/events/#"); }); client.on("message", (topic, payload) => { console.log(topic, payload.toString()); }); 35
  24. Three clients, one event Run Java, Python, and browser subscribers

    simultaneously. All subscribe to csc5100/events/#. Send ONE TemperatureLambda POST request. Watch the same JSON event arrive in three languages. HiveMQ public broker is for demonstration, not private data. 36
  25. Assignment 04 | the acknowledgment Subscribe to the topic for

    your assigned Lambda. Parse JSON; display the result and UUID. Publish an application ACK to csc5100/status/<uuid> at QoS 1. MQTT QoS 1 delivery is NOT the same as app-level processing ACK. Test the client and provide evidence in your final PR. 37
  26. Question 3 — Could AI use these Lambdas? Yes: the

    same HTTP APIs can be wrapped as AI-accessible tools. An MCP server can expose tools such as calculate_robot_distance. The MCP server calls our existing REST endpoints. 39
  27. Model Context Protocol (MCP) Connecting AI Applications to Tools and

    Services • MCP is an open standard that allows AI applications to discover and use external tools and data. • An MCP server exposes operations (tools) that an AI application can invoke. • These tools can connect to existing REST APIs, databases, or other services. • MCP provides an interface for AI applications to use them. • Key idea: Our existing Lambda services can become tools for AI applications without rewriting their core functionality. 40
  28. Next Step: AI + MCP AI assistant → MCP tool

    → REST API → Lambda. Example: “Compute robot distance and explain the result.” 41
  29. Start here Your assigned Story: https://github.com/CSC-Sandbox/5100-requirements/issues Code reference: src/main/java/edu/calpoly/lambdalab/instructor/ TemperatureLambda.java

    · TemperatureStorage.java TemperatureMessaging.java · EventProcessorLambda.java Your goal: one interoperable, observable, testable system. 42
  30. CSC 3100 Software Engineering Javier Gonzalez-Sanchez, Ph.D. [email protected] Fall 2026

    Copyright. These slides may be used only as study material for CSC 5100 within the California State University system. They may not be distributed or used for any other purpose.