public class Session extends Object implements Closeable
It performs sequencing and error recovery and represents a communication channel to a counter-party. Sessions are independent of specific communication layer connections. The Session could span many sequential connections (but cannot operate on multiple connection simultaneously).
A logical session is defined as starting with message sequence number 1 and ending when the session is reset. However, the Session object instance is registered when first created (per SessionID), and remains registered for the lifetime of the application (until the Connector is stopped), even across resets (which reset its internal state, such as the sequence number).
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_HEARTBEAT_TIMEOUT_MULTIPLIER |
static int |
DEFAULT_MAX_LATENCY |
static int |
DEFAULT_RESEND_RANGE_CHUNK_SIZE |
static double |
DEFAULT_TEST_REQUEST_DELAY_MULTIPLIER |
protected static org.slf4j.Logger |
LOG |
static String |
SETTING_ALLOW_UNKNOWN_MSG_FIELDS
Allow unknown fields in messages.
|
static String |
SETTING_ALLOWED_REMOTE_ADDRESSES |
static String |
SETTING_APP_DATA_DICTIONARY
Session setting specifying the path to the application data dictionary to use for
this session.
|
static String |
SETTING_CHECK_COMP_ID
If set to Y, messages must be received from the counterparty with the
correct SenderCompID and TargetCompID.
|
static String |
SETTING_CHECK_LATENCY
Session setting for enabling message latency checks.
|
static String |
SETTING_DATA_DICTIONARY
Session setting specifying the path to the data dictionary to use for
this session.
|
static String |
SETTING_DEFAULT_APPL_VER_ID |
static String |
SETTING_DESCRIPTION
Session description.
|
static String |
SETTING_DISABLE_HEART_BEAT_CHECK
Allow to disable heart beat failure detection
|
static String |
SETTING_DISCONNECT_ON_ERROR
Session setting for doing an automatic disconnect when an error occurs.
|
static String |
SETTING_ENABLE_LAST_MSG_SEQ_NUM_PROCESSED
Return the last msg seq number processed (optional tag 369).
|
static String |
SETTING_ENABLE_NEXT_EXPECTED_MSG_SEQ_NUM
Return the next expected message sequence number (optional tag 789 on Logon) on sent Logon message
and use value of tag 789 on received Logon message to synchronize session.
|
static String |
SETTING_END_DAY
Session scheduling setting to specify last day of trading week.
|
static String |
SETTING_END_TIME
Session scheduling setting to specify end time of the trading day.
|
static String |
SETTING_FORCE_RESEND_WHEN_CORRUPTED_STORE |
static String |
SETTING_HEARTBEAT_TIMEOUT_MULTIPLIER
Session setting for the heartbeat timeout multiplier (as fraction of heartbeat interval).
|
static String |
SETTING_HEARTBTINT
Session setting for heartbeat interval (in seconds).
|
static String |
SETTING_LOGON_TAG
Session setting for custom logon tags.
|
static String |
SETTING_LOGON_TIMEOUT
Session setting for logon timeout (in seconds).
|
static String |
SETTING_LOGOUT_TIMEOUT
Session setting for logout timeout (in seconds).
|
static String |
SETTING_MAX_LATENCY
Session setting for maximum message latency (in seconds).
|
static String |
SETTING_MAX_SCHEDULED_WRITE_REQUESTS |
static String |
SETTING_NON_STOP_SESSION
Session scheduling setting to specify that session never reset
|
static String |
SETTING_PERSIST_MESSAGES
Persist messages setting (true, by default).
|
static String |
SETTING_REFRESH_ON_LOGON
Requests that state and message data be refreshed from the message store at
logon, if possible.
|
static String |
SETTING_REJECT_GARBLED_MESSAGE
Reject garbled messages instead of ignoring them.
|
static String |
SETTING_REJECT_INVALID_MESSAGE |
static String |
SETTING_REJECT_MESSAGE_ON_UNHANDLED_EXCEPTION |
static String |
SETTING_REQUIRES_ORIG_SENDING_TIME |
static String |
SETTING_RESEND_REQUEST_CHUNK_SIZE
Setting to limit the size of a resend request in case of missing messages.
|
static String |
SETTING_RESET_ON_DISCONNECT
Session setting for doing an automatic sequence number reset on
disconnect.
|
static String |
SETTING_RESET_ON_ERROR
Session setting for doing an automatic reset when an error occurs.
|
static String |
SETTING_RESET_ON_LOGON
Session setting that causes the session to reset sequence numbers when initiating
a logon (>= FIX 4.2).
|
static String |
SETTING_RESET_ON_LOGOUT
Session setting for doing an automatic sequence number reset on logout.
|
static String |
SETTING_SEND_REDUNDANT_RESEND_REQUEST
Configures the session to send redundant resend requests (off, by default).
|
static String |
SETTING_START_DAY
Session scheduling setting to specify first day of trading week.
|
static String |
SETTING_START_TIME
Session scheduling setting to specify starting time of the trading day.
|
static String |
SETTING_TEST_REQUEST_DELAY_MULTIPLIER
Session setting for the test delay multiplier (as fraction of heartbeat interval).
|
static String |
SETTING_TIMESTAMP_PRECISION
Session setting to control precision in message timestamps.
|
static String |
SETTING_TIMEZONE
Session scheduling setting to specify time zone for the session.
|
static String |
SETTING_TRANSPORT_DATA_DICTIONARY
Session setting specifying the path to the transport data dictionary.
|
static String |
SETTING_USE_CLOSED_RESEND_INTERVAL
Use actual end of sequence gap for resend requests rather than using "infinity"
as the end sequence of the gap.
|
static String |
SETTING_USE_DATA_DICTIONARY
Session setting to indicate whether a data dictionary should be used.
|
static String |
SETTING_VALIDATE_CHECKSUM |
static String |
SETTING_VALIDATE_FIELDS_HAVE_VALUES
Session validation setting for enabling whether field values are
validated.
|
static String |
SETTING_VALIDATE_FIELDS_OUT_OF_ORDER
Default is "Y".
|
static String |
SETTING_VALIDATE_INCOMING_MESSAGE
Allow to bypass the message validation.
|
static String |
SETTING_VALIDATE_SEQUENCE_NUMBERS
Check the next expected target SeqNum against the received SeqNum.
|
static String |
SETTING_VALIDATE_UNORDERED_GROUP_FIELDS
Session validation setting for enabling whether field ordering is
validated.
|
static String |
SETTING_VALIDATE_USER_DEFINED_FIELDS
Controls validation of user-defined fields.
|
static String |
SETTING_WEEKDAYS
Session scheduling setting to specify active days of the week.
|
Modifier and Type | Method and Description |
---|---|
void |
addStateListener(SessionStateListener listener) |
void |
close()
Closes session resources and unregisters session.
|
void |
disconnect(String reason,
boolean logError)
Logs out from session and closes the network connection.
|
static boolean |
doesSessionExist(SessionID sessionID)
Determine if a session exists with the given ID.
|
protected static Integer |
extractExpectedSequenceNumber(String txt) |
void |
generateHeartbeat() |
void |
generateLogout() |
void |
generateTestRequest(String id) |
boolean |
getCheckCompID() |
DataDictionary |
getDataDictionary() |
DataDictionaryProvider |
getDataDictionaryProvider() |
int |
getExpectedSenderNum()
Retrieves the expected sender sequence number.
|
int |
getExpectedTargetNum()
Retrieves the expected target sequence number.
|
Log |
getLog() |
int |
getLogonTimeout() |
int |
getLogoutTimeout() |
int |
getMaxScheduledWriteRequests() |
MessageFactory |
getMessageFactory() |
boolean |
getRedundantResentRequestsAllowed() |
boolean |
getRefreshOnLogon() |
String |
getRemoteAddress()
Provides remote address of the session connection, if any.
|
boolean |
getResetOnDisconnect() |
boolean |
getResetOnLogout() |
Responder |
getResponder() |
ApplVerID |
getSenderDefaultApplicationVersionID() |
SessionID |
getSessionID() |
Date |
getStartTime() |
SessionStateListener |
getStateListener() |
MessageStore |
getStore()
Get the message store.
|
ApplVerID |
getTargetDefaultApplicationVersionID() |
double |
getTestRequestDelayMultiplier() |
boolean |
hasResponder()
This should not be used by end users.
|
boolean |
isAllowedForSession(InetAddress remoteInetAddress) |
boolean |
isEnabled()
Used internally
|
boolean |
isLoggedOn()
Is the session logged on.
|
boolean |
isLogonAlreadySent() |
boolean |
isLogonReceived() |
boolean |
isLogonSendNeeded() |
boolean |
isLogonSent() |
boolean |
isLogonTimedOut() |
boolean |
isLogoutReceived() |
boolean |
isLogoutSent() |
boolean |
isLogoutTimedOut() |
boolean |
isRejectGarbledMessage() |
boolean |
isSessionTime()
Predicate for determining if the session should be active at the current
time.
|
boolean |
isUsingDataDictionary() |
boolean |
isValidateChecksum() |
void |
logon()
This method can be used to manually logon to a FIX session.
|
void |
logout()
This method can be used to manually logout of a FIX session.
|
void |
logout(String reason)
This method can be used to manually logout of a FIX session.
|
static Session |
lookupSession(SessionID sessionID)
Locates a session specified by the provided session ID.
|
void |
next()
Called from the timer-related code in the acceptor/initiator
implementations.
|
void |
next(Message message)
(Internal use only)
|
static int |
numSessions()
Return the session count.
|
boolean |
receivedLogon()
Predicate indicating whether a logon message has been received.
|
boolean |
receivedLogout()
Predicate indicating whether a logout message has been received.
|
void |
removeStateListener(SessionStateListener listener) |
void |
reset()
Logs out session (if logged on) and then resets session state.
|
boolean |
send(Message message)
Send a message to a counterparty.
|
static boolean |
sendToTarget(Message message)
Send a message to the session specified in the message's target
identifiers.
|
static boolean |
sendToTarget(Message message,
SessionID sessionID)
Send a message to the session specified by the provided session ID.
|
static boolean |
sendToTarget(Message message,
String qualifier)
Send a message to the session specified in the message's target
identifiers.
|
static boolean |
sendToTarget(Message message,
String senderCompID,
String targetCompID)
Send a message to the session specified by the provided target company
ID.
|
static boolean |
sendToTarget(Message message,
String senderCompID,
String targetCompID,
String qualifier)
Send a message to the session specified by the provided target company
ID.
|
boolean |
sentLogon()
Predicate indicating whether a logon message has been sent.
|
boolean |
sentLogout()
Predicate indicating whether a logout message has been sent.
|
void |
setForceResendWhenCorruptedStore(boolean forceResendWhenCorruptedStore) |
void |
setHeartBeatInterval(int heartbeatInterval)
Internal use by acceptor code.
|
void |
setIgnoreHeartBeatFailure(boolean ignoreHeartBeatFailure) |
void |
setLogonTimeout(int seconds)
Sets the timeout for waiting for a logon response.
|
void |
setLogoutTimeout(int seconds)
Sets the timeout for waiting for a logout response.
|
void |
setMaxScheduledWriteRequests(int maxScheduledWriteRequests) |
void |
setNextSenderMsgSeqNum(int num)
Set the next outgoing message sequence number.
|
void |
setNextTargetMsgSeqNum(int num)
Set the next expected target message sequence number.
|
void |
setRejectGarbledMessage(boolean rejectGarbledMessage) |
void |
setRejectInvalidMessage(boolean rejectInvalidMessage) |
void |
setRejectMessageOnUnhandledException(boolean rejectMessageOnUnhandledException) |
void |
setRequiresOrigSendingTime(boolean requiresOrigSendingTime) |
void |
setResponder(Responder responder)
Registers a responder with the session.
|
void |
setTargetDefaultApplicationVersionID(ApplVerID applVerID)
Sets the default application version ID for messages received by this session.
|
void |
setValidateChecksum(boolean validateChecksum) |
String |
toString() |
public static final String SETTING_HEARTBTINT
public static final String SETTING_CHECK_LATENCY
public static final String SETTING_CHECK_COMP_ID
public static final String SETTING_MAX_LATENCY
public static final String SETTING_TEST_REQUEST_DELAY_MULTIPLIER
public static final String SETTING_HEARTBEAT_TIMEOUT_MULTIPLIER
public static final String SETTING_NON_STOP_SESSION
public static final String SETTING_START_DAY
public static final String SETTING_END_DAY
public static final String SETTING_TIMEZONE
public static final String SETTING_START_TIME
public static final String SETTING_END_TIME
public static final String SETTING_WEEKDAYS
public static final String SETTING_USE_DATA_DICTIONARY
public static final String SETTING_DATA_DICTIONARY
public static final String SETTING_TRANSPORT_DATA_DICTIONARY
public static final String SETTING_APP_DATA_DICTIONARY
DefaultApplVerID=FIX.4.2
AppDataDictionary=FIX42.xml
AppDataDictionary.FIX.4.4=FIX44.xml
This would use FIX42.xml for the default application version ID and FIX44.xml for
any FIX 4.4 messages.public static final String SETTING_VALIDATE_FIELDS_OUT_OF_ORDER
public static final String SETTING_VALIDATE_UNORDERED_GROUP_FIELDS
public static final String SETTING_VALIDATE_FIELDS_HAVE_VALUES
public static final String SETTING_VALIDATE_INCOMING_MESSAGE
public static final String SETTING_LOGON_TIMEOUT
public static final String SETTING_LOGOUT_TIMEOUT
public static final String SETTING_LOGON_TAG
public static final String SETTING_RESET_ON_LOGOUT
public static final String SETTING_VALIDATE_SEQUENCE_NUMBERS
public static final String SETTING_RESET_ON_DISCONNECT
public static final String SETTING_RESET_ON_ERROR
public static final String SETTING_DISCONNECT_ON_ERROR
public static final String SETTING_TIMESTAMP_PRECISION
public static final String SETTING_VALIDATE_USER_DEFINED_FIELDS
public static final String SETTING_RESET_ON_LOGON
public static final String SETTING_DESCRIPTION
public static final String SETTING_REFRESH_ON_LOGON
public static final String SETTING_SEND_REDUNDANT_RESEND_REQUEST
public static final String SETTING_PERSIST_MESSAGES
public static final String SETTING_USE_CLOSED_RESEND_INTERVAL
public static final String SETTING_ALLOW_UNKNOWN_MSG_FIELDS
public static final String SETTING_DEFAULT_APPL_VER_ID
public static final String SETTING_DISABLE_HEART_BEAT_CHECK
public static final String SETTING_ENABLE_LAST_MSG_SEQ_NUM_PROCESSED
public static final String SETTING_ENABLE_NEXT_EXPECTED_MSG_SEQ_NUM
public static final String SETTING_REJECT_GARBLED_MESSAGE
public static final String SETTING_REJECT_INVALID_MESSAGE
public static final String SETTING_REJECT_MESSAGE_ON_UNHANDLED_EXCEPTION
public static final String SETTING_REQUIRES_ORIG_SENDING_TIME
public static final String SETTING_FORCE_RESEND_WHEN_CORRUPTED_STORE
public static final String SETTING_ALLOWED_REMOTE_ADDRESSES
public static final String SETTING_RESEND_REQUEST_CHUNK_SIZE
public static final String SETTING_MAX_SCHEDULED_WRITE_REQUESTS
public static final String SETTING_VALIDATE_CHECKSUM
public static final int DEFAULT_MAX_LATENCY
public static final int DEFAULT_RESEND_RANGE_CHUNK_SIZE
public static final double DEFAULT_TEST_REQUEST_DELAY_MULTIPLIER
public static final double DEFAULT_HEARTBEAT_TIMEOUT_MULTIPLIER
protected static final org.slf4j.Logger LOG
public MessageFactory getMessageFactory()
public void setResponder(Responder responder)
responder
- a responder implementationpublic Responder getResponder()
public boolean hasResponder()
public String getRemoteAddress()
public static boolean sendToTarget(Message message) throws SessionNotFound
message
- a FIX messageSessionNotFound
- if session could not be locatedpublic static boolean sendToTarget(Message message, String qualifier) throws SessionNotFound
message
- a FIX messagequalifier
- a session qualifierSessionNotFound
- if session could not be locatedpublic static boolean sendToTarget(Message message, String senderCompID, String targetCompID) throws SessionNotFound
message
- a FIX messagesenderCompID
- the sender's company IDtargetCompID
- the target's company IDSessionNotFound
- if session could not be locatedpublic static boolean sendToTarget(Message message, String senderCompID, String targetCompID, String qualifier) throws SessionNotFound
message
- a FIX messagesenderCompID
- the sender's company IDtargetCompID
- the target's company IDqualifier
- a session qualifierSessionNotFound
- if session could not be locatedpublic static boolean sendToTarget(Message message, SessionID sessionID) throws SessionNotFound
message
- a FIX messagesessionID
- the target SessionIDSessionNotFound
- if session could not be locatedpublic static Session lookupSession(SessionID sessionID)
sessionID
- the session IDpublic void logon()
public void logout()
public void logout(String reason)
reason
- this will be included in the logout messagepublic boolean isEnabled()
public boolean sentLogon()
public boolean receivedLogon()
public boolean sentLogout()
public boolean receivedLogout()
public boolean isLoggedOn()
public void reset()
SessionState.reset()
public void setNextSenderMsgSeqNum(int num) throws IOException
num
- next outgoing sequence numberIOException
- IO errorpublic void setNextTargetMsgSeqNum(int num) throws IOException
num
- next expected target sequence numberIOException
- IO errorpublic int getExpectedSenderNum()
public int getExpectedTargetNum()
public Log getLog()
public MessageStore getStore()
public void next(Message message) throws FieldNotFound, RejectLogon, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType, IOException, InvalidMessage
public void generateLogout()
public void next() throws IOException
IOException
- IO errorpublic void generateHeartbeat()
public void generateTestRequest(String id)
public void disconnect(String reason, boolean logError) throws IOException
reason
- the reason why the session is disconnectedlogError
- set to true if this disconnection is an errorIOException
- IO errorpublic boolean send(Message message)
message
- the message to sendpublic DataDictionary getDataDictionary()
public DataDictionaryProvider getDataDictionaryProvider()
public SessionID getSessionID()
public boolean isSessionTime()
public static boolean doesSessionExist(SessionID sessionID)
sessionID
- public static int numSessions()
public void setLogonTimeout(int seconds)
seconds
- the timeout in secondspublic void setLogoutTimeout(int seconds)
seconds
- the timeout in secondspublic void setHeartBeatInterval(int heartbeatInterval)
heartbeatInterval
- public boolean getCheckCompID()
public int getLogonTimeout()
public int getLogoutTimeout()
public boolean getRedundantResentRequestsAllowed()
public boolean getRefreshOnLogon()
public boolean getResetOnDisconnect()
public boolean getResetOnLogout()
public boolean isLogonAlreadySent()
public boolean isLogonReceived()
public boolean isLogonSendNeeded()
public boolean isLogonSent()
public boolean isLogonTimedOut()
public boolean isLogoutReceived()
public boolean isLogoutSent()
public boolean isLogoutTimedOut()
public boolean isValidateChecksum()
public boolean isRejectGarbledMessage()
public boolean isUsingDataDictionary()
public Date getStartTime() throws IOException
IOException
public double getTestRequestDelayMultiplier()
public void addStateListener(SessionStateListener listener)
public void removeStateListener(SessionStateListener listener)
public SessionStateListener getStateListener()
public ApplVerID getSenderDefaultApplicationVersionID()
public ApplVerID getTargetDefaultApplicationVersionID()
public void setTargetDefaultApplicationVersionID(ApplVerID applVerID)
applVerID
- public int getMaxScheduledWriteRequests()
public void setMaxScheduledWriteRequests(int maxScheduledWriteRequests)
public void setIgnoreHeartBeatFailure(boolean ignoreHeartBeatFailure)
public void setRejectGarbledMessage(boolean rejectGarbledMessage)
public void setValidateChecksum(boolean validateChecksum)
public void setRejectInvalidMessage(boolean rejectInvalidMessage)
public void setRejectMessageOnUnhandledException(boolean rejectMessageOnUnhandledException)
public void setRequiresOrigSendingTime(boolean requiresOrigSendingTime)
public void setForceResendWhenCorruptedStore(boolean forceResendWhenCorruptedStore)
public boolean isAllowedForSession(InetAddress remoteInetAddress)
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2021. All rights reserved.