Skip to content

Commit

Permalink
#103 added some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioformosa committed Dec 11, 2022
1 parent 7fd174b commit 527ee12
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.fabioformosa.quartzmanager.api.configuration;

import it.fabioformosa.quartzmanager.api.common.config.QuartzManagerPaths;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
Expand All @@ -14,14 +15,16 @@ public class WebsocketConfig extends AbstractWebSocketMessageBrokerConfigurer {

@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableSimpleBroker("/topic");
config.setApplicationDestinationPrefixes("/job");
config.enableSimpleBroker("/topic"); //enable a simple memory-based message broker
// on destinations prefixed with /topic
config.setApplicationDestinationPrefixes("/job"); // it designates the prefix for messages
// that are bound for methods annotated with @MessageMapping
}

@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/quartz-manager/logs").setAllowedOrigins("/**").withSockJS();
registry.addEndpoint("/quartz-manager/progress").setAllowedOrigins("/**").withSockJS();
registry.addEndpoint(QuartzManagerPaths.QUARTZ_MANAGER_BASE_CONTEXT_PATH + "/logs").setAllowedOrigins("/**").withSockJS();
registry.addEndpoint(QuartzManagerPaths.QUARTZ_MANAGER_BASE_CONTEXT_PATH + "/progress").setAllowedOrigins("/**").withSockJS();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
@Controller
public class WebsocketController {

@MessageMapping({ QuartzManagerPaths.QUARTZ_MANAGER_BASE_CONTEXT_PATH + "/logs", QuartzManagerPaths.QUARTZ_MANAGER_BASE_CONTEXT_PATH + "/progress" })
@MessageMapping({
QuartzManagerPaths.QUARTZ_MANAGER_BASE_CONTEXT_PATH + "/logs",
QuartzManagerPaths.QUARTZ_MANAGER_BASE_CONTEXT_PATH + "/progress"
})
@SendTo("/topic/logs")
public String subscribe() {
return "subscribed";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class WebSocketLogsNotifier implements WebhookSender<LogRecord> {
private SimpMessageSendingOperations messagingTemplate;

@Override
public void send(LogRecord logRecord) {
public void send(LogRecord logRecord) {
messagingTemplate.convertAndSend(TOPIC_LOGS, logRecord);
}
}

0 comments on commit 527ee12

Please sign in to comment.