Answer the question
In order to leave comments, you need to log in
Spring Stomp + ActiveMQ and new destination addresses, how to be on the client?
It was necessary to install ActiveMQ instead of the standard broker in Spring. And here the problems with the Destination Name started because ActiveMQ will not work with / Therefore, what worked along the way /topic/action/{actionId}
will only work this way. /topic/action.{actionId}
The problem is that the client is an Android application, and it is necessary to force all users to reinstall this application. Is there a more humane way? Maybe you can specify in the Spring settings to rewrite some addresses when making requests in ActiveMQ ...
The code is painfully standard
@Override
public void configureMessageBroker(final MessageBrokerRegistry config) {
config.
enableStompBrokerRelay("/topic").
setRelayHost("localhost").
setRelayPort(61613).
setSystemLogin("admin").
setSystemPasscode("password");
config.setApplicationDestinationPrefixes("/app");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/ws")
.addInterceptors(new IpHandshakeInterceptor())
.setAllowedOrigins("*")
.withSockJS();
}
@MessageMapping("/action.{actionId}")
public void addMessage(SimpMessageHeaderAccessor sha, @DestinationVariable("actionId") String actionId, ChatMessage message) throws InterruptedException {
simpMessagingTemplate.convertAndSend("/topic/action." + actionId, message);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question