Interface FIXSession

All Known Subinterfaces:
ExtendedFIXSession, ScheduledFIXSession
All Known Implementing Classes:
AbstractFIXSession, AcceptorFIXSession, AutoreconnectFIXSession, InitiatorFIXSession

public interface FIXSession
This interface is the main interface user works with. It represents FIXSession either acceptor or initiator. And capable to send/receive messages.
  • Field Details

    • SEND_ASYNC

      static final int SEND_ASYNC
      ASYNC - Enqueue the message before sending as opposed to sending immediately from calling thread.
      See Also:
    • SEND_SYNC

      static final int SEND_SYNC
      FORCE_SYNC - Send the message synchronously.
      See Also:
    • DEFAULT_SENDING_OPTIONS

      static final int DEFAULT_SENDING_OPTIONS
      See Also:
  • Method Details

    • getSessionState

      SessionState getSessionState()
      Returns session state.
      Returns:
      SessionState - session state
    • prepareMessage

      FIXFieldList prepareMessage(FIXFieldList message, MessageStructure structure) throws PreparedMessageException
      Builds FIXFieldList object from FIXFieldList object.
      Parameters:
      message - FIXFieldList object
      structure - message structure
      Returns:
      FIXFieldList object
      Throws:
      PreparedMessageException - exception
    • prepareMessage

      FIXFieldList prepareMessage(FIXFieldList message, String type, MessageStructure structure) throws PreparedMessageException
      Builds FIXFieldList object from FIXFieldList object.
      Parameters:
      message - FIXFieldList object
      structure - message structure
      type - type of the message
      Returns:
      FIXFieldList object
      Throws:
      PreparedMessageException - exception
    • prepareMessage

      FIXFieldList prepareMessage(String msgType, MessageStructure userStructure) throws PreparedMessageException
      Builds FIXFieldList object with specified type, message structure and prefilled header information
      Parameters:
      msgType - message type
      userStructure - message structure
      Returns:
      FIXFieldList object
      Throws:
      PreparedMessageException
    • prepareMessageFromString

      FIXFieldList prepareMessageFromString(byte[] message, MessageStructure structure) throws PreparedMessageException
      Builds FIXFieldList object from String object.
      Parameters:
      message - message string
      structure - message structure object
      Returns:
      FIXFieldList object
      Throws:
      PreparedMessageException - exception
    • prepareMessageFromString

      FIXFieldList prepareMessageFromString(byte[] message, String type, MessageStructure structure) throws PreparedMessageException
      Builds FIXFieldList object from String object.
      Parameters:
      message - message string
      structure - message structure object
      type - message type
      Returns:
      FIXFieldList object
      Throws:
      PreparedMessageException - exception
    • resetSequenceNumbers

      void resetSequenceNumbers() throws IOException
      Allows user to reset sequences numbers by sending logon with 141=Y. Notice: Only supported for FIX versions 4.1 and above. Notice: The logon message will be send only when session is in connected state.
      Throws:
      IOException
    • resetSequenceNumbers

      void resetSequenceNumbers(boolean checkGapFillBefore) throws IOException
      Allows user to reset sequences numbers by sending logon with 141=Y. Notice: Only supported for FIX versions 4.1 and above. Notice: The logon message will be send only when session is in connected state.
      Parameters:
      checkGapFillBefore - - the flag indicates if needed to check the seq num.

      If true the TR will be sent before introday logon otherwise only intraday logon will be sent.

      Throws:
      IOException
    • setSequenceNumbers

      void setSequenceNumbers(long inSeqNum, long outSeqNum) throws IOException
      Allows user to change sequences numbers for disconnected sessions.
      Parameters:
      inSeqNum - new incoming sequence number. If new value is < 0, then this parameter will be ignored.
      outSeqNum - new outgoing sequence number. If new value is < 0, then this parameter will be ignored.
      Throws:
      IOException
    • getSessionParameters

      SessionParameters getSessionParameters()
      Returns the cloned session connection parameters instance.
      Returns:
      SessionParameters - session parameters
    • init

      void init() throws IOException
      Initialize FIX session. This allows to put messages to session. These messages will be send after connect.
      Throws:
      IOException - I/O exception if error occurred
    • connect

      void connect() throws IOException
      Connects to remote counterparty, if initiator or accepts incoming connection if acceptor.
      Throws:
      IOException - I/O exception if error occurred
    • reject

      void reject(String reason) throws IOException
      Reject incoming connection for acceptor. Not applicable for initiator.
      Throws:
      IOException - I/O exception if error occurred
    • disconnect

      void disconnect(String reason)
      Gracefully disconnects current session. Logoff with specified reason will be sent to your counterparty. Note: This method doesn't guarantee immediate shutdown, since FIX protocol require us to wait for counterparty logoff reply.
      Parameters:
      reason - the reason
    • sendMessage

      boolean sendMessage(String msgType, FIXFieldList content)
      Convenient method to send out FIX message based on the message type and message content. Depending on implementation and configuration may send message immediately or put it in the outgoing queue either persistent or stateless. If the msgType is null, Engine sends the message as is; If the msgType is "", Engine updates body length, sequence number, sending time and checksum fields; Otherwise Engine wraps the content.

      If session is disposed no more messages should be send by session.

      Parameters:
      msgType - the message type (Tag 35 content)
      content - the message content
      Returns:
      true if message was send immediately, false - message was queued for later sending
      Throws:
      IllegalStateException - if session is disposed
    • sendMessage

      boolean sendMessage(String msgType, FIXFieldList content, int optionMask)
      Convenient method to send out FIX message based on the message type and message content. Depending on implementation and configuration may send message immediately or put it in the outgoing queue either persistent or stateless. If the msgType is null, Engine sends the message as is; If the msgType is "", Engine updates body length, sequence number, sending time and checksum fields; Otherwise Engine wraps the content.

      If session is disposed no more messages should be send by session.

      Parameters:
      msgType - the message type (Tag 35 content)
      content - the message content
      optionMask - SEND_SYNC or SEND_ASYNC
      Returns:
      true if message was send immediately, false - message was queued for later sending
      Throws:
      IllegalStateException - if session is disposed
    • sendMessage

      boolean sendMessage(FIXFieldList message)
      Convenient method to send out user built FIX message. Depending on implementation and configuration may send message immediately or put it in the outgoing queue either persistent or stateless. The Engine updates the footer and header in the message .

      If session is disposed no more messages should be send by session.

      Parameters:
      message - the message
      Returns:
      true if message was send immediately, false - message was queued for later sending
      Throws:
      IllegalStateException - if session is disposed
    • sendMessage

      boolean sendMessage(FIXFieldList message, int optionMask)
      Convenient method to send out user built FIX message. Depending on implementation and configuration may send message immediately or put it in the outgoing queue either persistent or stateless. The Engine updates the footer and header in the message .

      If session is disposed no more messages should be send by session.

      Parameters:
      message - the message
      optionMask - SEND_SYNC or SEND_ASYNC
      Returns:
      true if message was send immediately, false - message was queued for later sending
      Throws:
      IllegalStateException - if session is disposed
    • sendAsIs

      boolean sendAsIs(FIXFieldList message)
      Convenient method to send out FIX message based on the message type and message content. Depending on implementation and configuration may send message immediately or put it in the outgoing queue either persistent or stateless. The Engine sends the message as is.

      If session is disposed no more messages should be send by session.

      Parameters:
      message - the message content
      Returns:
      true if message was send immediately, false - message was queued for later sending
      Throws:
      IllegalStateException - if session is disposed
    • sendAsIs

      boolean sendAsIs(FIXFieldList message, int optionMask)
      Convenient method to send out FIX message based on the message type and message content. Depending on implementation and configuration may send message immediately or put it in the outgoing queue either persistent or stateless. The Engine sends the message as is.

      If session is disposed no more messages should be send by session.

      Parameters:
      message - the message content
      optionMask - SEND_SYNC or SEND_ASYNC
      Returns:
      true if message was send immediately, false - message was queued for later sending
      Throws:
      IllegalStateException - if session is disposed
    • sendWithChanges

      boolean sendWithChanges(FIXFieldList content, ChangesType allowedChangesType)
      Convenient method to send out FIX message based on the message type and message content. Depending on implementation and configuration may send message immediately or put it in the outgoing queue either persistent or stateless. The Engine sends the message as is.

      If session is disposed no more messages should be send by session.

      Parameters:
      content - the message content
      allowedChangesType - the parameter takes the next values:
      Returns:
      true if message was send immediately, false - message was queued for later sending
      Throws:
      IllegalStateException - if session is disposed
      See Also:
    • sendWithChanges

      boolean sendWithChanges(FIXFieldList content, ChangesType allowedChangesType, int optionMask)
      Convenient method to send out FIX message based on the message type and message content. Depending on implementation and configuration may send message immediately or put it in the outgoing queue either persistent or stateless. The Engine sends the message as is.

      If session is disposed no more messages should be send by session.

      Parameters:
      content - the message content
      allowedChangesType - the parameter takes the next values:
      optionMask - SEND_SYNC or SEND_ASYNC
      Returns:
      true if message was send immediately, false - message was queued for later sending
      Throws:
      IllegalStateException - if session is disposed
      See Also:
    • dispose

      void dispose()
      Disposes current session, removes its reference from GlobalSessionManager and frees all allocated resources. Normally should be called after disconnect(). However it is possible to call this method for active session without previous disconnect() that will abnormally terminate fix session by closing fix connection (without logon exchange). This is useful to terminate stuck sessions if standard FIX logoff procedure doesn't work.
    • getMessageValidator

      MessageValidator getMessageValidator()
      Returns message validator.
      Returns:
      message validator for current session
    • getMessageValidator

      MessageValidator getMessageValidator(String appVersion)
      Returns message validator by appVersion.
      Parameters:
      appVersion -
      Returns:
      message validator by appVersion
    • getMessageValidator

      MessageValidator getMessageValidator(String appVersion, FIXVersion baseFixVersion)
      Returns message validator by appVersion. Validates for compliance with the basic version
      Parameters:
      appVersion - - appVersion from message
      baseFixVersion - - base version for appVersion from message/session
      Returns:
      message validator by appVersion
      Throws:
      IllegalArgumentException - if appVersion and baseMessage incorrect values
    • setFIXSessionListener

      void setFIXSessionListener(FIXSessionListener listener)
      Sets FIXSession listener to monitor session status and receive incoming messages.
      Parameters:
      listener - the user specified listener
    • addInSessionLevelMessageListener

      void addInSessionLevelMessageListener(FIXMessageListener listener)
      Add listeners to receive session level incoming messages. FIX session level message type:
      • 'A' - Logon
      • '0' - Heartbeat
      • '1' - Test Request
      • '2' - Resend Request
      • '3' - Reject
      • '4' - Sequence Reset
      • '5' - Logout
      Parameters:
      listener - the user specified listener
    • addOutSessionLevelMessageListener

      void addOutSessionLevelMessageListener(com.epam.fixengine.session.TypedFIXMessageListener listener)
    • addUserGlobalMessageHandler

      void addUserGlobalMessageHandler(com.epam.fixengine.session.messagehandler.AbstractUserGlobalMessageHandler userMessageHandler)
    • setErrorHandler

      void setErrorHandler(ErrorHandler handler)
      Sets error handler.
      Parameters:
      handler - the error handler
      See Also:
    • setRejectMessageListener

      void setRejectMessageListener(RejectMessageListener listener)
      Sets reject listener.
      Parameters:
      listener - the reject message listener
      See Also:
    • setSlowConsumerListener

      void setSlowConsumerListener(FIXSessionSlowConsumerListener slowConsumerListener)
      Sets slow consumer message listener.
      Parameters:
      slowConsumerListener - slow consumer listener
      See Also:
    • setInSeqNum

      void setInSeqNum(long inSeqNum) throws IOException
      Throws:
      IOException
    • setOutSeqNum

      void setOutSeqNum(long outSeqNum) throws IOException
      Throws:
      IOException
    • getInSeqNum

      long getInSeqNum()
    • getOutSeqNum

      long getOutSeqNum()