Integrating Spring controllers message mapping and Artemis
<p>I'm researching switching to WildFly 10 and, subsequently, Artemis. I've set up a simple Spring Websocket project, as described here: <a href="https://spring.io/guides/gs/messaging-stomp-websocket/" rel="nofollow">https://spring.io/guides/gs/messaging-stomp-websocket/</a>.
The meat of the project are WebSocketConfig:</p>

<pre><code>@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
    config.enableStompBrokerRelay("/queue/", "/topic/");
    config.setApplicationDestinationPrefixes("/app");
}
</code></pre>

<p>And controller:</p>

<pre><code>@MessageMapping("/hello")
@SendTo("/topic/greetings")
public Greeting greeting(HelloMessage message) throws Exception {
    return new Greeting("Hello, " + message.getName() + "!");
}
</code></pre>

<p>This works like a charm as it is with ActiveMQ, no additional configuration required on the broker side.</p>

<p>Knowing that Artemis requires either a pre-created destination, or a specific mention of automatic queue creation, i added this to my broker.xml:</p>

<pre><code>&lt;address-setting match="#"&gt;
    &lt;dead-letter-address&gt;jms.queue.DLQ&lt;/dead-letter-address&gt;
    &lt;expiry-address&gt;jms.queue.ExpiryQueue&lt;/expiry-address&gt;
    &lt;redelivery-delay&gt;0&lt;/redelivery-delay&gt;
    &lt;max-size-bytes&gt;10485760&lt;/max-size-bytes&gt;
    &lt;message-counter-history-day-limit&gt;10&lt;/message-counter-history-day-limit&gt;
    &lt;address-full-policy&gt;BLOCK&lt;/address-full-policy&gt;
    &lt;auto-create-jms-queues&gt;true&lt;/auto-create-jms-queues&gt;
    &lt;/address-setting&gt;
&lt;/address-settings&gt;
</code></pre>

<p>However, this didn't work as i expected and broker still refused to create <code>/queue/greetings</code>. So, i've researched a bit more and found that Artemis, in fact, likes queues to be names with <code>jms.queue.*</code> prefix. I renamed my queue to <code>jms.queue.greetings</code> and made the following changes to Spring code:
<strong>Configuration:</strong></p>

<pre><code>...
config.setPathMatcher(new AntPathMatcher("."));
...
</code></pre>

<p><strong>Controller:</strong></p>

<pre><code>...
@SendTo("jms.queue.greetings")
...
</code></pre>

<p>To my understanding, this should have forced my controller to send messages to this queue. Broker liked this change and finally created the queue, but Spring controller on the other hand did not - no messages appear in jms.queue.greetings.</p>

<p>I can force my way around the issue by making code less pretty, subscribing to required queues with some hand-made injected services, but that way i will loose Spring sockJS magic - Artemis (unlike RabbitMQ) doesn't seem to provide <code>http</code> endpoint to Stomp, and connecting to <code>ws://</code> will just lead to CORS errors. No inbuilt CORS support either, it seems.</p>

<p>I will appreciate any thoughts on how i might overcome this issue.</p>

<p>EDIT:
My JS looks like this:</p>

<pre><code>var ws = new SockJS('/hello');
client = Stomp.over(ws);
...
client.connect(login, passcode, function(frame) {
    client.debug("connected to Stomp");
    ....
    client.subscribe('jms.queue.greetings', function(message) {
        ...
    });
});
...
client.send("jms.queue.greetings", {}, JSON.stringify({ 'name': text }));
...
</code></pre>