activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danbucatanschi <>
Subject Re: Dynamic management of composite destinations
Date Wed, 10 Jun 2009 17:39:05 GMT

Hi chutny,

Sorry for replying so late. I was on vacation for a while.

I ended up programming my own classes to handle this situation and put them
in a package that gets loaded up in ActiveMQ using the Spring XML config
file. Here is a short summary of what I did. It should get you started if
you want to do something similar (I cannot share my own code since it
contains some custom parts to my organization regarding the connection to a
database for dynamic configuration of ActiveMQ).

1. Create your own classes:
  a. FeedInterceptor implements
     This will intercept all new destinations in ActiveMQ. It can match the
new destinations to any wildcard using a
org.apache.activemq.filter.DestinationMap. This way you can figure out
whether this is a regular destination, a virtual one, or a forwarded one
(maybe filtered) that's part of the virtual destination. It returns the
appropriate Destination depending on the match, (i.e. it can return a that I don't
reimplement it again, or a regular Destination, or my own custom
FilteredQueueDestinationFilter--see below)

  b. FilteredQueueDestinationFilter extends
      This can be configured on the fly when created in the FeedInterceptor
(above) and this way it can have a filter set up (or no filter) so that it
can decide whether to send the message (that's about to be sent) on this
destination or not. For filtering it uses a
org.apache.activemq.filter.BooleanExpression that gets evaluated with every
call to its send method.

2. Configure ActiveMQ:
In activemq.xml the destinationInterceptors tag has to look like:

      <bean xmlns=""
            id="CustomFeeds" class="com.yourdomain.FeedInterceptor">
            <!-- Optional properties are here,
                   such as the virtual destinations you want to use,
                   or the filters you want to use for particular forward
                   destinations -->
            <property name="prop1" ref="prop-value"/>

      <!-- You should still be able to use any of the classical ActiveMQ
             but you have to be careful with naming conflicts that can
arise. -->
           <virtualTopic name=">" prefix="VirtualTopicConsumers.*." />

The filter you can use with the BooleanExpression should be any selector you
can write for JMS since it is the same mechanism that ActiveMQ uses for
filtering JMS messages. The advantage of this is that the filtering happens
inside ActiveMQ and this way the client has no control over it. On top of
that the client can still use their own selector to further filter messages
they receive (for example for load balancing).

Good luck with it. Reply back if you have further questions. :)


chutny wrote:
> Hi,
>   I have the similar requirement, were you able to figure out a
> solution.Currently planning to set up a delegatemessage listener which
> will read all the messages from Queue and will process the messages based
> on some simple message selection logic . Am restricting the subscribers to
> enter simple message selectors like "=" not full SQL92 expression . 

View this message in context:
Sent from the ActiveMQ - Dev mailing list archive at

View raw message