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