I am implementing a WebSockets application using Spring WebSockets.
As a STOMP broker, I want to use Wildfly's Artemis (Active MQ).
I did the following configuration in standalone-full.xml:
Adding the following acceptor:
<acceptor name="stomp-acceptor" factory-class="org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory"> <param name="protocols" value="STOMP" /> <param name="port" value="61613" /> </acceptor>
add a new application user guest/guest to application-users.properties using add-user.bat
add the following StompConfiguration (abbreviated):
@Configuration @EnableWebSocketMessageBroker public class StompConfiguration extends AbstractWebSocketMessageBrokerConfigurer { @Override public void registerStompEndpoints(StompEndpointRegistry registry) { registry.addEndpoint("/ws").setAllowedOrigins("*").withSockJS(); } @Override public void configureMessageBroker(MessageBrokerRegistry config) { config.setApplicationDestinationPrefixes("/app"); config.enableStompBrokerRelay("/topic", "/queue").setRelayHost("localhost").setRelayPort(61613) .setClientLogin("guest").setClientPasscode("guest"); } }
This seems to work well at startup:
16:57:13,890 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 64) AMQ221020: Started Acceptor at localhost:61613 for protocols [STOMP] 16:57:13,892 INFO [org.apache.activemq.artemis.core.server] (ServerService Thread Pool -- 64) AMQ221007: Server is now live
However, wenn I send the first message using Spring's SimpMessagingTemplate:
template.convertAndSend(topic, payload);
I get the error
ERROR [org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler] (reactor-tcp-io-1) Received ERROR {message=[AMQ339001: Destination does not exist: /topic/abc/12345/xyz]} session=system
Using Stomp, it should not be necessary to create a topic beforehand. How can I tell Artemis to create it automatically?