@Override public void run() { Session.lookupSession(sessionId).send(message); }
/** * Send a message to the session specified in the message's target * identifiers. * * @param message a FIX message * @return true is send was successful, false otherwise * @throws SessionNotFound if session could not be located */ public static boolean sendToTarget(Message message) throws SessionNotFound { return sendToTarget(message, ""); }
@Override public void onCreate(SessionID sessionId) { logger.info("Session created: {}", sessionId); this.sessionId = sessionId; Session.lookupSession(sessionId).logon(); }
/** * Closes session resources and unregisters session. This is for internal * use and should typically not be called by an user application. */ @Override public void close() throws IOException { closeIfCloseable(getLog()); closeIfCloseable(getStore()); // clean up session just in case close() was not called from Session.unregisterSession() unregisterSession(this.sessionID, false); }
/** * Closes session resources. This is for internal use and should typically * not be called by an user application. */ @Override public void close() throws IOException { closeIfCloseable(getLog()); closeIfCloseable(getStore()); }
final String msgType = header.getString(MsgType.FIELD); initializeHeader(header); header.setInt(LastMsgSeqNumProcessed.FIELD, getExpectedTargetNum() - 1); application.toAdmin(message, sessionID); } catch (final Throwable t) { logApplicationException("toAdmin()", t); resetState(); message.getHeader().setInt(MsgSeqNum.FIELD, getExpectedSenderNum()); if (MsgType.LOGON.equals(msgType) || MsgType.LOGOUT.equals(msgType) || MsgType.RESEND_REQUEST.equals(msgType) || MsgType.SEQUENCE_RESET.equals(msgType) || isLoggedOn()) { result = send(messageString); return false; } catch (final Throwable t) { logApplicationException("toApp()", t); if (isLoggedOn()) { result = send(messageString); logThrowable(getLog(), "Error reading/writing in MessageStore", e); return false; } catch (final FieldNotFound e) {
final Message heartbeat = messageFactory.create(sessionID.getBeginString(), MsgType.HEARTBEAT); initializeHeader(heartbeat.getHeader()); heartbeat.getHeader().setInt(MsgSeqNum.FIELD, i); messages.add(heartbeat.toString()); msg = parseMessage(message); msgSeqNum = msg.getHeader().getInt(MsgSeqNum.FIELD); } catch (final Exception e) { getLog().onErrorEvent( "Error handling ResendRequest: failed to parse message (" + e.getMessage() + "): " + message); initializeResendFields(msg); if (resendApproved(msg)) { if (begin != 0) { generateSequenceReset(receivedMessage, begin, msgSeqNum); getLog().onEvent("Resending message: " + msgSeqNum); send(msg.toString()); begin = 0; appMessageJustSent = true; generateSequenceReset(receivedMessage, begin, msgSeqNum + 1); } else { generateSequenceResetIfNeeded(receivedMessage, newBegin, endSeqNo, msgSeqNum); generateSequenceReset(receivedMessage, begin, msgSeqNum + 1);
public void refresh() throws IOException { // IOException is declared to maintain strict compatibility with QF JNI final String text = "memory store does not support refresh!"; final Session session = sessionID != null ? Session.lookupSession(sessionID) : null; if (session != null) { session.getLog().onErrorEvent("ERROR: " + text); } else { LoggerFactory.getLogger(MemoryStore.class).error(text); } }
protected Session findQFSession(IoSession ioSession, SessionID sessionID) { Session quickfixSession = findQFSession(ioSession); if (quickfixSession == null) { quickfixSession = Session.lookupSession(sessionID); } return quickfixSession; }
protected void logoutAllSessions(boolean forceDisconnect) { log.info("Logging out all sessions"); if (sessions == null) { log.error("Attempt to logout all sessions before initialization is complete."); return; } for (Session session : sessions.values()) { try { session.logout(); } catch (Throwable e) { logError(session.getSessionID(), null, "Error during logout", e); } } if (anyLoggedOn()) { if (forceDisconnect) { for (Session session : sessions.values()) { try { if (session.isLoggedOn()) { session.disconnect("Forcibly disconnecting session", false); } } catch (Throwable e) { logError(session.getSessionID(), null, "Error during disconnect", e); } } } else { waitForLogout(); } } }
private void sendMessage(SessionID sessionID, Message message) { try { Session session = Session.lookupSession(sessionID); if (session == null) { throw new SessionNotFound(sessionID.toString()); } DataDictionaryProvider dataDictionaryProvider = session.getDataDictionaryProvider(); if (dataDictionaryProvider != null) { try { dataDictionaryProvider.getApplicationDataDictionary( getApplVerID(session, message)).validate(message, true); } catch (Exception e) { LogUtil.logThrowable(sessionID, "Outgoing message failed validation: " + e.getMessage(), e); return; } } session.send(message); } catch (SessionNotFound e) { log.error(e.getMessage(), e); } }
public TabularData getLoggedOnSessions() throws OpenDataException { List<ObjectName> names = new ArrayList<>(); for (SessionID sessionID : connector.getSessions()) { Session session = Session.lookupSession(sessionID); if (session.isLoggedOn()) { names.add(sessionExporter.getSessionName(sessionID)); } } return tabularDataAdapter.fromArray("Sessions", "SessionID", toObjectNameArray(names)); }
/** * Get the data dictionary for the given session. * * @param inSessionId a <code>Message</code> value * @return a <code>DataDictionary</code> value * @throws FieldNotFound if the FIX version could not be determined from the given message * @throws UnsupportedOperationException if the given session ID does not correspond to an active session */ public static DataDictionary getDataDictionary(SessionID inSessionId) throws FieldNotFound { Session session = Session.lookupSession(inSessionId); if(session == null) { throw new UnsupportedOperationException(Messages.MISSING_SESSION.getText(session)); } quickfix.field.ApplVerID applVerId = session.getTargetDefaultApplicationVersionID(); return getDataDictionary(FIXVersion.getFIXVersion(applVerId)); } /**
public void logout() { for (SessionID sessionId : initiator.getSessions()) { Session.lookupSession(sessionId).logout("user requested"); } }
private MessageDispatchingThread(Session session, int queueCapacity, Executor executor) { super("QF/J Session dispatcher: " + session.getSessionID(), executor); quickfixSession = session; messages = new LinkedBlockingQueue<>(queueCapacity); }
private void handleExceptionAndRejectMessage(final String msgType, final Message message, final HasFieldAndReason e) throws FieldNotFound, IOException { if (MsgType.LOGON.equals(msgType)) { logoutWithErrorMessage(e.getMessage()); } else { getLog().onErrorEvent("Rejecting invalid message: " + e + ": " + getMessageToLog(message)); generateReject(message, e.getMessage(), e.getSessionRejectReason(), e.getField()); } }
private void resetIfSessionNotCurrent(SessionID sessionID, long time) throws IOException { if (!isCurrentSession(time)) { getLog().onEvent("Session state is not current; resetting " + sessionID); reset(); } }
private boolean logErrorAndDisconnectIfRequired(final Exception e, Message message) { final boolean resetOrDisconnectIfRequired = resetOrDisconnectIfRequired(message); if (resetOrDisconnectIfRequired) { getLog().onErrorEvent("Encountered invalid message: " + e + ": " + getMessageToLog(message)); } return resetOrDisconnectIfRequired; }
synchronized void start() { if (reconnectFuture == null) { // The following logon reenabled the session. The actual logon will take // place as a side-effect of the session timer task (not the reconnect task). reconnectTask.getFixSession().logon(); // only enables the session reconnectFuture = executor .scheduleWithFixedDelay(reconnectTask, 0, 1, TimeUnit.SECONDS); } }
public void processMessage() { try { quickfixSession.next(message); } catch (Throwable e) { LogUtil.logThrowable(quickfixSession.getSessionID(), e.getMessage(), e); } } }