3

I am using Artemis 2.6.2 with STOMP only and the following constellation:

Broker:

  • No queues configured in broker.xml, everything is auto created.

Server:

  • SUBSCRIBE to destination TaskResponse without selector/filter
  • SEND to destination TaskRequest with header clientId = ID (the ID of the client what the server would request to)

Client 123:

  • SUBSCRIBE to destination TaskRequest with selector clientId = 123
  • SEND to destination TaskResponse with header clientId = 123

When I watch at the Artemis Console the following happens:

  1. No server and no client is connected: No address or queue is present

  2. Server connect: Artemis creates a multicast address TaskResponse and a multicast queue for this address with empty filter

  3. Client 123 connect: Artemis creates a multicast address TaskRequest and a multicast queue for this address with filter clientId = 123

  4. Message exchange: Messages are transfered from server to client and back to server as expected.

  5. Client 123 disconnect: Artemis removes the multicast address TaskRequest and the coresponding multicast queue with filter clientId = 123

  6. Server sends message to TaskRequest for client 123: According to STOMP client on server the message is sent successful. On the broker the message disappears.

  7. Same behavior vice versa: Client 123 is connected and server is not: According to STOMP client on client 123 the message is sent successful. On the broker the message disappears.

My guess is that the message is discarded because there is no route to a subscriber. If I enable the option "send-to-dla-on-no-route" in address-settings section of broker.xml the message goes directly to dead letter queue.

Do you know a way to preserve the messages until the subscriber reconnects?

Appendix 1: STOMP Messages

I am using the Stomp.Net Library with SelectorsCore Example but reduced only to selector s1. The workflow is a bit other than what I wrote above.

Unfortunately I did not found an example to enable logging of STOMP messages into a file in Artemis. Therefore I recorded the packets with WireShark, exported as text and uploaded into Gist StompMessages.txt. You can see there the diffrent STOMP messages, e.g. search for CONNECT, SEND, etc.

Solution

The solution was to use the option anycastPrefix=/queue/ in the acceptor element in broker.xml to force the queues to type ANYCAST:

<acceptor name="stomp">tcp://0.0.0.0:61613?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=STOMP;useEpoll=true;anycastPrefix=/queue/</acceptor>
BiNZGi
  • 1,347
  • 1
  • 14
  • 19

1 Answers1

0

What you are observing is the expected behavior. If you send a message to an address with no queues (or in STOMP terms - a destination with no subscribers) then the message will have nowhere to go and will be discarded. This is normal pub/sub semantics.

If you want to preserve the messages even if no subscriber is present you can either:

  1. Use anycast (i.e. point-to-point) semantics rather than multicast. This is discussed in the Artemis documentation.
  2. Use "durable" STOMP subscribers as discussed in the Artemis documentation. The caveat here is that the subscription will still need to be created before messages are sent and you will also need to make sure you remove the subscription when you are done with it or it may accumulate messages.
Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
  • Thank you for the fast answer. I will check the two mentioned options... – BiNZGi Aug 15 '18 at 09:33
  • I have checked the two propositions. Unfortunately they need both adjustments on the STOMP client. Do you know a way to reach the behavior by changing only the broker config? Something interessting I found is that I could not force the broker to auto create durable queues. In the [docs](https://activemq.apache.org/artemis/docs/latest/address-model.html#configuring-addresses-and-queues-via-address-settings) it says: `Queues which are auto-created are durable, non-temporary, and non-transient.` – BiNZGi Aug 15 '18 at 16:04
  • I'd need to know more about what exactly the client is doing to provide any additional input. Do you have a series of STOMP frames you could share that demonstrate the client's behavior? – Justin Bertram Aug 15 '18 at 16:45
  • I have added details in the original question with Appendix 1. Thank you for having a look. – BiNZGi Aug 16 '18 at 13:30
  • I looked into [StompConnection.java](https://github.com/apache/activemq-artemis/blob/532317cefffd4c276958f9ec163fca263c67873d/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java#L302): `session.createQueue(simpleQueue, simpleQueue, routingType == null ? addressSettings.getDefaultQueueRoutingType() : routingType, null, false, true, true);` I see that the durable flag in this method call is null and java is probably using false as default. That would be a contradiction to the quoted documentation in the comment above. – BiNZGi Aug 22 '18 at 10:33
  • The `null` being passed there is for the `filterString`, not the durable flag. See https://github.com/apache/activemq-artemis/blob/532317cefffd4c276958f9ec163fca263c67873d/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java#L164. – Justin Bertram Aug 22 '18 at 13:24
  • Sorry for the wrong investigation in the source code. Meanwhile I found some other hint. I tried on another server which had artemis 2.4.0 running. There the behavoir is different. The queues are created durable and the messages are kept as I would expect it. I am going to try with Version 2.5.0 and let you know. – BiNZGi Aug 22 '18 at 14:03
  • I tested with 2.5.0 and it works the same as with 2.6.2. It seem there is a change between 2.4.0 und 2.5.0. I have checked the [Release Notes of 2.5.0](https://activemq.apache.org/artemis/release-notes-2.5.0.html) and have only found two tickets with durable. I think they are not related to the changed behavoir. – BiNZGi Aug 22 '18 at 15:07
  • At this point I'm not sure what's not working for you, what your client is doing, what you expect to happen, and what the broker is actually doing. Perhaps you could start a thread on the ActiveMQ user mailing list - http://activemq.apache.org/mailing-lists.html. – Justin Bertram Aug 22 '18 at 15:14
  • I have already done that [here](http://activemq.2283324.n4.nabble.com/Artemis-keep-messages-with-no-route-td4742273.html) but the only response was from you saying your answer is on StackOverflow ;( Do you think my finding "Using STOMP with Artemis 2.4.0 creates durable queues and 2.5.0 and above creates non-durable queues" is worth a bug report? – BiNZGi Aug 22 '18 at 15:26
  • You should raise the issue about 2.4 vs 2.5 durable vs. non-durable on the ActiveMQ mailing list as that is much more specific than your previous email (which was a duplicate of this question). The more specific the question the likelier it is to get an answer. – Justin Bertram Aug 22 '18 at 16:16
  • Thanks for clarification. I put together the details and make a new post on the list in the next days. I close this question and mark your answer as accepted. Thank you for the help. – BiNZGi Aug 22 '18 at 19:21