|
1 |
| -// Copyright (c) 2022, 2023 IBM Corporation and others. |
| 1 | +// Copyright (c) 2022, 2024 IBM Corporation and others. |
2 | 2 | // Licensed under Creative Commons Attribution-NoDerivatives
|
3 | 3 | // 4.0 International (CC BY-ND 4.0)
|
4 | 4 | // https://creativecommons.org/licenses/by-nd/4.0/
|
|
13 | 13 | :page-essential: false
|
14 | 14 | :page-description: Learn how to use Jakarta WebSocket to stream messages between client and server services.
|
15 | 15 | :guide-author: Open Liberty
|
16 |
| -:page-tags: ['Jakarta EE'] |
| 16 | +:page-tags: ['jakarta-ee'] |
17 | 17 | :page-related-guides: ['grpc-intro']
|
18 | 18 | :page-permalink: /guides/{projectid}
|
19 | 19 | :imagesdir: /img/guide/{projectid}
|
@@ -135,7 +135,7 @@ Annotate the `SystemService` class with a [hotspot=serverEndpoint file=0]`@Serve
|
135 | 135 |
|
136 | 136 | The [hotspot=onOpenMethod file=0]`onOpen()` method stores up the client sessions. The [hotspot=onCloseMethod file=0]`onClose()` method displays the reason for closing the connection and removes the closing session from the client sessions.
|
137 | 137 |
|
138 |
| -The [hotspot=onMessageMethod file=0]`onMessage()` method is called when receiving a message through the `option` parameter. The [hotspot=loadAverage hotspot=memoryUsageOrBoth file=0]`option` parameter signifies which message to construct, either system load, memory usage data, or both, and sends out the [hotspot=sendToAllSessions file=0]`JsonObject` message. The [hotspot=sendToAllSessionseMethod file=0]`sendToAllSessions()` method uses the WebSocket API to broadcast the message to all client sessions. |
| 138 | +The [hotspot=onMessageMethod file=0]`onMessage()` method is called when receiving a message through the `option` parameter. The [hotspot=cpuLoad hotspot=memoryUsageOrBoth file=0]`option` parameter signifies which message to construct, either system load, memory usage data, or both, and sends out the [hotspot=sendToAllSessions file=0]`JsonObject` message. The [hotspot=sendToAllSessionseMethod file=0]`sendToAllSessions()` method uses the WebSocket API to broadcast the message to all client sessions. |
139 | 139 |
|
140 | 140 | [role="code_command hotspot file=1", subs="quotes"]
|
141 | 141 | ----
|
@@ -229,7 +229,7 @@ SystemLoadScheduler.java
|
229 | 229 | include::finish/client/src/main/java/io/openliberty/guides/client/scheduler/SystemLoadScheduler.java[]
|
230 | 230 | ----
|
231 | 231 |
|
232 |
| -The `SystemLoadScheduler` class uses the [hotspot=systemClient file=1]`SystemClient` class to establish a connection to the server by the `ws://localhost:9081/systemLoad` URI at the [hotspot=postConstruct file=1]`@PostConstruct` annotated method. The [hotspot=sendSystemLoad file=1]`sendSystemLoad()` method calls the client to send a random string from either [hotspot=messages file=1]`loadAverage`, [hotspot=messages file=1]`memoryUsage`, or [hotspot=messages file=1]`both` to the `system` service. Using the link:https://openliberty.io/docs/latest/reference/javadoc/liberty-jakartaee9.1-javadoc.html?package=jakarta/ejb/package-frame.html&class=jakarta/ejb/TimerService.html[Jakarta Enterprise Beans Timer Service^], annotate the `sendSystemLoad()` method with the [hotspot=schedule file=1]`@Schedule` annotation so that it sends out a message every 10 seconds. |
| 232 | +The `SystemLoadScheduler` class uses the [hotspot=systemClient file=1]`SystemClient` class to establish a connection to the server by the `ws://localhost:9081/systemLoad` URI at the [hotspot=postConstruct file=1]`@PostConstruct` annotated method. The [hotspot=sendSystemLoad file=1]`sendSystemLoad()` method calls the client to send a random string from either [hotspot=messages file=1]`cpuLoad`, [hotspot=messages file=1]`memoryUsage`, or [hotspot=messages file=1]`both` to the `system` service. Using the link:https://openliberty.io/docs/latest/reference/javadoc/liberty-jakartaee9.1-javadoc.html?package=jakarta/ejb/package-frame.html&class=jakarta/ejb/TimerService.html[Jakarta Enterprise Beans Timer Service^], annotate the `sendSystemLoad()` method with the [hotspot=schedule file=1]`@Schedule` annotation so that it sends out a message every 10 seconds. |
233 | 233 |
|
234 | 234 | Now, create the front-end UI. The images and styles for the UI are provided for you.
|
235 | 235 |
|
|
0 commit comments