SessionName destinationSessionName = destination.getDestination();
boolean destinationIsSession = destinationSessionName.isSession();
boolean forceQueing = destination.forceQueuing();
boolean wantsPtP = true; // TODO if destination never has logged in spam would be possible!
SubjectInfo destinationClient = null;
// Handle PtP to subject in a thread safe manner
if (!destinationIsSession) { // -> subject
// 3 + 6 (force queing ignored since same reaction for both)
destinationClient = authenticate.getSubjectInfoByName(destination.getDestination());
if (!forceQueing && destinationClient==null) {
String tmp = ME+": Sending PtP message '" + cacheEntry.getLogId() + "' to '" + destination.getDestination() + "' failed, the destination is unkown, the message rejected.";
//log.warning(tmp); is logged by caller already
throw new XmlBlasterException(serverScope, ErrorCode.USER_PTP_UNKNOWNDESTINATION, ME, tmp +
" Client is not logged in and <destination forceQueuing='true'> is not set");
}
if (log.isLoggable(Level.FINE)) log.fine(ME+": Queuing PtP message '" + cacheEntry.getLogId() + "' for subject destination [" + destination.getDestination() + "], forceQueing="+forceQueing);
// We are responsible to call destinationClient.getLock().release()
final boolean returnLocked = true;
destinationClient = authenticate.getOrCreateSubjectInfoByName(destination.getDestination(), returnLocked, null, null);
try {
MsgQueueUpdateEntry msgEntrySubject = new MsgQueueUpdateEntry(serverScope, cacheEntry,
destinationClient.getSubjectQueue().getStorageId(), destination.getDestination(),
Constants.SUBSCRIPTIONID_PtP, false);
destinationClient.queueMessage(msgEntrySubject);
continue;
}
finally {
destinationClient.getLock().release();
}
}
// Handle PtP to session in a thread safe manner
SessionInfo receiverSessionInfo = null;