Skip to content

Conversation

georgweiss
Copy link
Collaborator

@georgweiss georgweiss commented Aug 27, 2025

This PR adds web sockets to Olog ES clients (Log Entry Table and Log Entry Calendar).

As the implementation uses Spring Framework web socket libs, new dependencies are added, total ~2MB. If Olog is not used, site specific products should exclude core-websocket to avoid these dependencies.

A dedicated class WebSocketClientService is intended to be somewhat generic. It handles reconnections as well as keep-alive (aka ping/pong).

The idea is to skip polling for new log entries twice per minute, but rather rely on web socket messages dispatched from the associated Olog service.

NOTE: the Olog web client will through this PR depend on Olog/phoebus-olog#220.

@shroffk
Copy link
Member

shroffk commented Aug 27, 2025

this is great,
can we wait till a new release before merging this since it has breaking changes

@georgweiss
Copy link
Collaborator Author

@shroffk, do you mean a new release of Olog or Phoebus? Or both?

(msg, ex) -> {
searchInProgress.set(false);
ExceptionDetailsErrorDialog.openError(Messages.LogbooksSearchFailTitle, ex.getMessage(), null);
//ExceptionDetailsErrorDialog.openError(Messages.LogbooksSearchFailTitle, ex.getMessage(), null);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented-out code.

public void shutdown() {
cancelPeriodSearch();
@Override
public void handleWebSocketMessage(String message) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If two new log entries are created more or less simultaneously, will this function be called in parallel, or will the two calls occur sequentially (in that case, presumably on the same thread)?

public void handleWebSocketMessage(String message) {
try {
WebSocketMessage webSocketMessage = objectMapper.readValue(message, WebSocketMessage.class);
if (webSocketMessage.messageType().equals(MessageType.NEW_LOG_ENTRY)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the two other message types (MessageType.LOG_ENTRY_UPDATED and MessageType.SHOW_BANNER) also be handled by this function?


setupTextAreaContextMenu();

//doStompStuff();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented-out code.

}
}

private void doStompStuff(){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is not called. (The only call to it (on line 559) is commented out.)

}

/**
*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty comment.

* Disconnects the STOMP session if non-null and connected.
*/
public void disconnect() {
if(stompSession != null && stompSession.isConnected()) {
Copy link
Collaborator

@abrahamwolk abrahamwolk Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this class need to be made thread-safe, perhaps by means of synchronization? E.g., could stompSession be assigned to between the check stompSession != null, the check stompSession.isConnected(), and the call stompSession.disconnect()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think this needs to be synchronized. stompSession is null only initially, i.e. as long as API client has not called connect and the connection attempt succeeds. Hence the null check.

@georgweiss
Copy link
Collaborator Author

Additions based on feedback from collaboration peers: add backwards compatibility, i.e. if service does not support web sockets, fall back to periodic polling of log entries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants