Rather than filtering on the client side using selectors (which leave
messages behind in the queues) you can filter inside the broker at the
virtual destination itself. That way only messages that apply get placed on
the queue to begin with:

    <destinationInterceptors>
      <virtualDestinationInterceptor>
        <virtualDestinations>
          <compositeQueue name="orders">
            <forwardTo>
              <filteredDestination selector="odd = 'yes'"
queue="orders.odd"/>
              <filteredDestination selector="odd = 'no'"
queue="orders.even"/>
            </forwardTo>
          </compositeQueue>
        </virtualDestinations>
      </virtualDestinationInterceptor>
    </destinationInterceptors>


The only thing that I would add is that there is a quirk around when those
queues get created - off the top of my head it is when a client first
connects to consume messages from them. Fortunately, you can get around it
by defining the queues up front in a destinations block
(http://activemq.apache.org/configure-startup-destinations.html):

    <destinations>
      <queue physicalName="orders.odd" />
      <queue physicalName="orders.even" />
    </destinations>

Hope that helps.

Jakub

--
View this message in context: 
http://activemq.2283324.n4.nabble.com/Messages-are-sent-to-all-Queues-instead-of-specific-queues-in-Virtual-Topic-tp4653895p4653903.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to