//-------------------------------------------------------------------------
protected boolean dispatchMessages(Subscription subscription, boolean dispatched) throws JMSException {
ActiveMQMessage[] msgs = subscription.getMessagesToDispatch();
if (msgs != null && msgs.length > 0) {
BrokerClient client = (BrokerClient) subscriptions.get(subscription);
if (client == null) {
log.warn("Null client for subscription: " + subscription);
}
else {
for (int i = 0; i < msgs.length; i++) {
ActiveMQMessage msg = msgs[i].shallowCopy();
if (log.isDebugEnabled()) {
log.debug("Dispatching message: " + msg);
}
int[] consumerNos = new int[1];
consumerNos[0] = subscription.getConsumerNumber();
msg.setConsumerNos(consumerNos);
client.dispatch(msg);
dispatched = true;
}
}
}
return dispatched;