* route, store and forward a message
*/
public void processMessage(IMQConnection con, Packet msg)
throws BrokerException, SelectorFormatException, IOException
{
DataHandler handler = (DataHandler)
pr.getHandler(PacketType.MESSAGE);
Destination d = null;
PacketReference ref = null;
Set s = null;
boolean route = false;
boolean isadmin = con.isAdminConnection();
try {
d = Destination.getDestination(
msg.getDestination(), msg.getIsQueue());
if (d == null) {
throw new BrokerException("Unknown Destination:" + msg.getDestination());
}
Producer pausedProducer = handler.checkFlow(msg, con);
boolean transacted = (msg.getTransactionID() != 0);
if (DEBUG) {
Globals.getLogger().log(Logger.INFO,
"ProtocolImpl.PROCESS MESSAGE["+msg+"]TID="+msg.getTransactionID()+" on connection "+con);
}
// OK generate a ref. This checks message size and
// will be needed for later operations
ref = handler.createReference(msg, d.getDestinationUID(), con, isadmin);
// dont bother calling route if there are no messages
//
// to improve performance, we route and later forward
route = handler.queueMessage(d, ref, transacted);
s = handler.routeMessage(transacted, ref, route, d);
// handle producer flow control
handler.pauseProducer(d, pausedProducer, con);
} catch (BrokerException ex) {
int status = ex.getStatusCode();
if (status == Status.ERROR && ref!= null && d != null)
handler.cleanupOnError(d, ref);
// rethrow
throw ex;
}
if (route && d != null && s != null) {
handler.forwardMessage(d, ref, s);
}
}