22.6. Caution with Addresses with Multiple Queues

When a message is routed to an address that has multiple queues bound to it; for example a JMS subscription, there is only one copy of the message in memory. Each queue only deals with a reference to this. This means that the memory is only freed up once all queues referencing the message have delivered it.
For example:
  • An address has ten queues
  • One of the queues does not deliver its messages (maybe because of a slow consumer).
  • Messages continually arrive at the address and paging is started.
  • The other nine queues are empty even though messages have been sent.
In this example the process has to wait until the last queue has delivered some of its messages before the process can depage and the other queues finally receive some more messages.

Important

Message selectors will only operate on messages in memory. If you have a large amount of messages paged to disk and a selector that only matches some of the paged messages, those messages will not be consumed until the messages in memory have been consumed.
HornetQ does not scan through page files on disk to locate matching messages. This is not the primary role of a messaging system. A relational database is recommended for implementations using selectors to select small subsets of messages in very large queues, because this functionality is similar to executing queries over tables in a relational database.

Important

Do not set page-size-bytes (on the server) to a value lower than ack-batch-size (in the client) or your system may appear to hang.
Messages remain in server memory until they are acknowledged the server, therefore contributing to message sizes on a particular address.
If messages are paged to disk for an address, and are being consumed, they will be depaged from disk when enough memory has been freed up in that address after messages have been consumed and acknowledged. However if messages are not acknowledged then more messages will not be depaged since there is no free space in memory. In this case message consumption can appear to hang.
If a message is not acknowledged explicitly, it will be acknowledged according to the "ack-batch-size" setting in the client.