General principles for publish/subscribe messaging using ASF
ConnectionConsumers receive messages for a specified Topic. A ConnectionConsumer can be durable or non-durable. We must specify which queue or queues the ConnectionConsumer uses.
When an application creates a ConnectionConsumer from a TopicConnection object, it specifies a Topic object and a selector string. The ConnectionConsumer then begins to receive messages that match the selector on that Topic, including any retained publications for the topic subscribed to.
Alternatively, an application can create a durable ConnectionConsumer that is associated with a specific name. This ConnectionConsumer receives messages that have been published on the Topic since the durable ConnectionConsumer was last active. It receives all such messages that match the selector on the Topic. However, if the ConnectionConsumer is using read-ahead, it can lose nonpersistent messages that are in the client buffer when it closes.
If IBM MQ classes for JMS is in IBM MQ messaging provider migration mode, a separate queue is used for non-durable ConnectionConsumer subscriptions. The CCSUB configurable option on the TopicConnectionFactory specifies the queue to use. Normally, the CCSUB specifies a single queue for use by all ConnectionConsumers that use the same TopicConnectionFactory. However, it is possible to make each ConnectionConsumer generate a temporary queue by specifying a queue name prefix followed by an asterisk (*).
If IBM MQ classes for JMS is in IBM MQ messaging provider migration mode, the CCDSUB property of the Topic specifies the queue to use for durable subscriptions. Again, this can be a queue that already exists or a queue name prefix followed by an asterisk (*). If you specify a queue that already exists, all durable ConnectionConsumers that subscribe to the Topic use this queue. If you specify a queue name prefix followed by an asterisk (*), a queue is generated the first time that a durable ConnectionConsumer is created with a particular name. This queue is reused later when a durable ConnectionConsumer is created with the same name.
When you set up the IBM MQ queue manager, consider the following points:
- Your queue manager must have an enabled dead-letter queue. If a ConnectionConsumer experiences a problem when it puts a message on the dead-letter queue, message delivery from the underlying QLOCAL stops. To define a dead-letter queue, use:
ALTER QMGR DEADQ( your.dead.letter.queue.name )- The user that runs the ConnectionConsumer must have authority to perform MQOPEN with MQOO_SAVE_ALL_CONTEXT and MQOO_PASS_ALL_CONTEXT. For details, see the IBM MQ documentation for the platform.
- We can optimize performance for an individual ConnectionConsumer by creating a separate, dedicated, queue for it. This is at the cost of extra resource usage.
Parent topic: Plan an application with ASF