return remotingClientSessionID;
}
boolean sendMessage(JBossMessage msg, Transaction tx, boolean checkForDuplicates) throws Exception
{
JBossDestination dest = (JBossDestination)msg.getJMSDestination();
if (!dest.isDirect())
{
long msgID = serverPeer.getMessageIDMgr().getID();
msg.setMessageId(msgID);
}
// Trace after the messageID was generated
if (trace) { log.trace(this + " sending message " + msg + (tx == null ? " non-transactionally" : " in " + tx)); }
// This allows the no-local consumers to filter out the messages that come from the same
// connection.
msg.setConnectionID(id);
// We must reference the message *before* we send it the destination to be handled. This is
// so we can guarantee that the message doesn't disappear from the store before the
// handling is complete. Each channel then takes copies of the reference if they decide to
// maintain it internally
MessageReference ref = msg.createReference();
if (checkForDuplicates)
{
if (serverPeer.getPersistenceManagerInstance().idExists(msg.getJMSMessageID()))
{
log.trace("ID exists in ID cache, probably duplicate sent on failover");
return false;
}
}
long schedDeliveryTime = msg.getScheduledDeliveryTime();
if (schedDeliveryTime > 0)
{
ref.setScheduledDeliveryTime(schedDeliveryTime);
}
if (dest.isDirect())
{
if (trace) { log.trace(this + " routing " + msg + " to direct destination"); }
//Route directly to queue - temp kludge for clustering
Binding binding = postOffice.getBindingForQueueName(dest.getName());
if (binding == null)
{
throw new IllegalArgumentException("Cannot find binding for queue " + dest.getName());
}
Queue queue = binding.queue;
Long scid = (Long)ref.getMessage().removeHeader(Message.SOURCE_CHANNEL_ID);
Delivery del = queue.handleMove(ref, scid.longValue());
if (del == null)
{
throw new JMSException("Failed to route " + ref + " to " + dest.getName());
}
}
else if (dest.isQueue())
{
if (trace) { log.trace(this + " routing " + msg + " to queue"); }
if (!postOffice.route(ref, new JMSCondition(true, dest.getName()), tx))
{
throw new JMSException("Failed to route " + ref + " to " + dest.getName());
}
}
else
{
if (trace) { log.trace(this + " routing " + msg + " to postoffice"); }
postOffice.route(ref, new JMSCondition(false, dest.getName()), tx);
}
if (trace) { log.trace("sent " + msg); }
return true;