// concat a full group id, this is for when a binding has multiple bindings
SimpleString fullID = groupId.concat(".").concat(routingName);
// see if there is already a response
Response resp = groupingGroupingHandler.getProposal(fullID);
if (resp == null)
{
// ok lets find the next binding to propose
Binding theBinding = getNextBinding(message, routingName, bindings);
// TODO https://jira.jboss.org/jira/browse/HORNETQ-191
resp = groupingGroupingHandler.propose(new Proposal(fullID, theBinding.getClusterName()));
// if our proposal was declined find the correct binding to use
if (resp.getAlternativeClusterName() != null)
{
theBinding = null;
for (Binding binding : bindings)
{
if (binding.getClusterName().equals(resp.getAlternativeClusterName()))
{
theBinding = binding;
break;
}
}
}
// and lets route it
if (theBinding != null)
{
theBinding.route(message, context);
}
else
{
throw new HornetQException(HornetQException.QUEUE_DOES_NOT_EXIST,
"queue " + resp.getChosenClusterName() +
" has been removed cannot deliver message, queues should not be removed when grouping is used");
}
}
else
{
// ok, we need to find the binding and route it
Binding chosen = null;
for (Binding binding : bindings)
{
if (binding.getClusterName().equals(resp.getChosenClusterName()))
{
chosen = binding;
break;
}
}
if (chosen != null)
{
chosen.route(message, context);
}
else
{
throw new HornetQException(HornetQException.QUEUE_DOES_NOT_EXIST,
"queue " + resp.getChosenClusterName() +
" has been removed cannot deliver message, queues should not be removed when grouping is used");
}
}
}
}