activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dejan Bosanac <de...@nighttale.net>
Subject Re: PolicyMap api is really bad :-(
Date Wed, 11 Jan 2012 19:46:10 GMT
Hi,

there are a lot of examples on how to use destination in unit tests. For
example, how to set default destination policy see

https://fisheye6.atlassian.com/browse/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/policy/IndividualDeadLetterTest.java?hb=true

or how to set it for a specific destinations see

https://fisheye6.atlassian.com/browse/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/UnlimitedEnqueueTest.java?r=911650

Regards
-- 
Dejan Bosanac - http://twitter.com/dejanb
-----------------
The experts in open source integration and messaging - http://fusesource.com
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net


On Wed, Jan 11, 2012 at 3:51 AM, Jason Dillon <jason@planet57.com> wrote:

> Hiya, I'm trying to programmatically configure the destination policies
> via PolicyMap and I'm not exactly sure how this component is expected to
> behave.  Looks like a lot of this behavior is magical (eh evil?) xbean
> stuff.
>
> To get around this and provide a better API I created this:
>
> <snip>
> public class ExtPolicyMap
>    extends PolicyMap
> {
>    @NonNls
>    private static final Logger log =
> LoggerFactory.getLogger(ExtPolicyMap.class);
>
>    @ScriptAccessible
>    public PolicyEntry forQueue(final String name) {
>        log.debug("Looking up policy-entry for queue: {}", name);
>        PolicyEntry entry = getEntryFor(new ActiveMQQueue(name));
>        if (entry == null) {
>            entry = new PolicyEntry();
>            entry.setQueue(name);
>            put(entry.getDestination(), entry);
>        }
>        log.debug("Entry: {}", entry);
>        return entry;
>    }
>
>    @ScriptAccessible
>    public PolicyEntry forTopic(final String name) {
>        log.debug("Looking up policy-entry for topic: {}", name);
>        PolicyEntry entry = getEntryFor(new ActiveMQTopic(name));
>        if (entry == null) {
>            entry = new PolicyEntry();
>            entry.setTopic(name);
>            put(entry.getDestination(), entry);
>        }
>        log.debug("Entry: {}", entry);
>        return entry;
>    }
> }
> </snip>
>
> And then exposed via:
>
> <snip>
> public class ExtBrokerService
>    extends SslBrokerService
> {
>    public ExtBrokerService() {
>        // Force our version of the policy map to be used
>        setDestinationPolicy(new ExtPolicyMap());
>    }
>
>    @Override
>    public ExtPolicyMap getDestinationPolicy() {
>        return (ExtPolicyMap) super.getDestinationPolicy();
>    }
> }
> </snip>
>
> And then I can go configure things like:
>
> <snip>
> service.getDestinationPolicy().forQueue(">").setOptimizedDispatch(true);
> service.start();
> </snip>
>
> I'm not sure how to easily verify if this is correct or not, so I wanted
> to know if this looks sane.  Given use of ExtBrokerService here with
> ExtPolicyMap, will this properly configure optimizeDispatch for all queues?
>
> --jason
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message