MDBs and selectors
The selector for an MDB is set in the EJB deployment descriptor. Unlike the previous discussion on generic JMS and selectors, the selection process is done by the code in the message listener service not in code written by the application developer. The message listener service monitors all the queues it is responsible for, and together with the JMS provider, will do the work of matching message to MDB selector.
Keeping the depth of the queue (number of messages on queue) to a minimum always increases the speed of using message selectors as there are less messages to parse. When using MDBs with message selectors in point-to-point, always make sure to have all messages that arrive on a queue dealt with. Any messages that do not match the selection criteria for the MDBs monitoring that queue, will be left sitting on the queue. Over time they could build up and slow down the selection process.
Either make sure that the MDBs that use selectors on a message queue, cover all possibilities for arriving messages, or use one of the configuration options to remove the unselected messages.
Depending on your application it could be possible to specify an expiry for messages on the queue.
An alternative is to disable message retention. The message listener service will check all the selector strings of it's MDBs against each message that arrives. If it does not find a match then the default is for this message to be returned to the queue. The setting that is controlling this behavior is MSGRETENTION(YES) being set on the QCF object.
This setting is configurable from the WAS Administrative Console for a QCF under the WebSphere MQ JMS provider. Figure 15-11 shows where this can be found on the QCF page.
Disable message retention on the QCF
To disable message retention, uncheck the box next to Enable message retention, save the configuration and restart any appserver using this QCF. This will now mean that if the message listener service cannot match a message against one of the MDB selectors that are registered on it, the message will be placed on the queue manager's dead letter queue with an appropriate reason code.
This setting will change behavior for all parts of the application that are accessing a queue on a queue manager through this QCF. Use this setting only when you are confident that it will not affect any other part of the application. Also, each queue can only have one process that is using selectors on it through this QCF. If there is more than one process, for example the message listener service and a QueueReceiver running in a Web container thread, then there is a danger that messages will be lost.
Multiple MDBs with selectors can be pointing at the same QCF (through their listener port) as they are handled by one process, the message listener service.
WebSphere is a trademark of the IBM Corporation in the United States, other countries, or both.
IBM is a trademark of the IBM Corporation in the United States, other countries, or both.