Process of purging and removing AMQ selectors

Solution Verified - Updated -

Environment

  • Red Hat JBoss A-MQ 6.x
  • Red Hat JBoss Fuse 6.x

Issue

  • What are the best practices on removing selectors
  • How to ensure selector cache is cleared when removing consumer applications which use selectors

Resolution

This is only applicable to brokers with the virtualSelectorCacheBrokerPlugin configured.

Option 1 - deleting individual selectors

Installing the virtualSelectorCacheBrokerPlugin should instantiate a JMX mbean that will allow listing, deleting individual and purging all selectors for a given consumer queue.

These operations are exposed via Hawtio under the "plugins" tree of the broker view (see attached screenshot).

  • Click on the "selectorsForDestination" operation, you should see a a dialog box for specifying the destination.

  • To list the selectors for a particular queue, fill in the box with the queue name in URI format, like "queue://Consumer.1.MyVirtualTopic" and click the "execute" button.
    You should see a list of selectors.

  • If you have more than one selector listed, this would be an indication of some problem (note that the single word "TRUE" is also a selector that essentially means "all") - either the client has been restarted with a new selector, or perhaps an additional client has started with the same consumer prefix.

  • After viewing the selectors, you can opt to execute either the

    • "deleteAllSelectorsForDestination" operation to clear the selector cache for the given consumer queue (using the URI format, as above),
    • deleteSelectorForDestination operation. This operation takes two arguments:
      The destination name in URI format, as above, and the the selector expression you wish to delete.

Option 2 - Deleting all selectors

  • Alternatively, you can purge all cached selectors by stopping the broker, deleting the selectorcache.data file and starting the broker back up.
  • Location of selectorcache.data file can be found in the broker configuration
<virtualSelectorCacheBrokerPlugin persistFile="${data}/selectorcache.data" singleSelectorPerDestination="true"/>

Will Selectors be recreated?

  • The selectors should be recreated when the consumers connect to the broker.

virtualDestinationCache

Diagnostic Steps

Selectors should be removed from cache when

  • There is an update to the selectors
  • There are duplicate selectors

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments