@Override public void dispatchForSync(Message msg) { if (msg != null) { final MessageHandler handler = msg.getMessageHandler(); // cant be null NonBlockingSession session = (NonBlockingSession) handler; MessageQueue queue = session.getSendSyncQueue(); if (queue != null) { queue.add(msg); } else { // @TODO add ReusableString write( ReusableString buf ) to Message and log details // should NEVER happen _log.error(MISSING_HANDLER, ((Session) handler).getComponentId()); } } }
/** * @param session - a non blocking session ie an NIO one that wont block if socket cant read/write */ @Override public synchronized void addSession(final NonBlockingSession session) { SessionWrapper[] newSessions = new SessionWrapper[_sessions.length + 1]; int idx = 0; while (idx < _sessions.length) { newSessions[idx] = _sessions[idx]; ++idx; } newSessions[idx] = new SessionWrapper(session, session.getSendQueue(), session.getSendSyncQueue()); _sessions = newSessions; _fullyFlushed = false; }