Package com.epam.fixengine
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
ASYNC - Enqueue the message before sending as opposed to sending immediately from calling thread.static final int
FORCE_SYNC - Send the message synchronously. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add listeners to receive session level incoming messages.void
addOutSessionLevelMessageListener
(com.epam.fixengine.session.TypedFIXMessageListener listener) void
addUserGlobalMessageHandler
(com.epam.fixengine.session.messagehandler.AbstractUserGlobalMessageHandler userMessageHandler) void
connect()
Connects to remote counterparty, if initiator or accepts incoming connection if acceptor.void
disconnect
(String reason) Gracefully disconnects current session.void
dispose()
Disposes current session, removes its reference from GlobalSessionManager and frees all allocated resources.long
Returns message validator.getMessageValidator
(String appVersion) Returns message validator by appVersion.getMessageValidator
(String appVersion, FIXVersion baseFixVersion) Returns message validator by appVersion.long
Returns the cloned session connection parameters instance.Returns session state.void
init()
Initialize FIX session.prepareMessage
(FIXFieldList message, MessageStructure structure) Builds FIXFieldList object from FIXFieldList object.prepareMessage
(FIXFieldList message, String type, MessageStructure structure) Builds FIXFieldList object from FIXFieldList object.prepareMessage
(String msgType, MessageStructure userStructure) Builds FIXFieldList object with specified type, message structure and prefilled header informationprepareMessageFromString
(byte[] message, MessageStructure structure) Builds FIXFieldList object from String object.prepareMessageFromString
(byte[] message, String type, MessageStructure structure) Builds FIXFieldList object from String object.void
Reject incoming connection for acceptor.void
Allows user to reset sequences numbers by sending logon with 141=Y.void
resetSequenceNumbers
(boolean checkGapFillBefore) Allows user to reset sequences numbers by sending logon with 141=Y.boolean
sendAsIs
(FIXFieldList message) Convenient method to send out FIX message based on the message type and message content.boolean
sendAsIs
(FIXFieldList message, int optionMask) Convenient method to send out FIX message based on the message type and message content.boolean
sendMessage
(FIXFieldList message) Convenient method to send out user built FIX message.boolean
sendMessage
(FIXFieldList message, int optionMask) Convenient method to send out user built FIX message.boolean
sendMessage
(String msgType, FIXFieldList content) Convenient method to send out FIX message based on the message type and message content.boolean
sendMessage
(String msgType, FIXFieldList content, int optionMask) Convenient method to send out FIX message based on the message type and message content.boolean
sendWithChanges
(FIXFieldList content, ChangesType allowedChangesType) Convenient method to send out FIX message based on the message type and message content.boolean
sendWithChanges
(FIXFieldList content, ChangesType allowedChangesType, int optionMask) Convenient method to send out FIX message based on the message type and message content.void
setErrorHandler
(ErrorHandler handler) Sets error handler.void
setFIXSessionListener
(FIXSessionListener listener) Sets FIXSession listener to monitor session status and receive incoming messages.void
setInSeqNum
(long inSeqNum) void
setOutSeqNum
(long outSeqNum) void
Sets reject listener.void
setSequenceNumbers
(long inSeqNum, long outSeqNum) Allows user to change sequences numbers for disconnected sessions.void
setSlowConsumerListener
(FIXSessionSlowConsumerListener slowConsumerListener) Sets slow consumer message listener.
-
Field Details
-
SEND_ASYNC
static final int SEND_ASYNCASYNC - Enqueue the message before sending as opposed to sending immediately from calling thread.- See Also:
-
SEND_SYNC
static final int SEND_SYNCFORCE_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 objectstructure
- 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 objectstructure
- message structuretype
- 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 typeuserStructure
- 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 stringstructure
- 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 stringstructure
- message structure objecttype
- message type- Returns:
- FIXFieldList object
- Throws:
PreparedMessageException
- exception
-
resetSequenceNumbers
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
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
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
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
Connects to remote counterparty, if initiator or accepts incoming connection if acceptor.- Throws:
IOException
- I/O exception if error occurred
-
reject
Reject incoming connection for acceptor. Not applicable for initiator.- Throws:
IOException
- I/O exception if error occurred
-
disconnect
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
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 themsgType
is null, Engine sends the message as is; If themsgType
is "", Engine updates body length, sequence number, sending time and checksum fields; Otherwise Engine wraps thecontent
.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
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 themsgType
is null, Engine sends the message as is; If themsgType
is "", Engine updates body length, sequence number, sending time and checksum fields; Otherwise Engine wraps thecontent
.If session is disposed no more messages should be send by session.
- Parameters:
msgType
- the message type (Tag 35 content)content
- the message contentoptionMask
-SEND_SYNC
orSEND_ASYNC
- Returns:
- true if message was send immediately, false - message was queued for later sending
- Throws:
IllegalStateException
- if session is disposed
-
sendMessage
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 themessage
.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
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 themessage
.If session is disposed no more messages should be send by session.
- Parameters:
message
- the messageoptionMask
-SEND_SYNC
orSEND_ASYNC
- Returns:
- true if message was send immediately, false - message was queued for later sending
- Throws:
IllegalStateException
- if session is disposed
-
sendAsIs
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
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 contentoptionMask
-SEND_SYNC
orSEND_ASYNC
- Returns:
- true if message was send immediately, false - message was queued for later sending
- Throws:
IllegalStateException
- if session is disposed
-
sendWithChanges
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 contentallowedChangesType
- 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
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 contentallowedChangesType
- the parameter takes the next values:optionMask
-SEND_SYNC
orSEND_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
Returns message validator by appVersion.- Parameters:
appVersion
-- Returns:
- message validator by appVersion
-
getMessageValidator
Returns message validator by appVersion. Validates for compliance with the basic version- Parameters:
appVersion
- - appVersion from messagebaseFixVersion
- - base version for appVersion from message/session- Returns:
- message validator by appVersion
- Throws:
IllegalArgumentException
- if appVersion and baseMessage incorrect values
-
setFIXSessionListener
Sets FIXSession listener to monitor session status and receive incoming messages.- Parameters:
listener
- the user specified listener
-
addInSessionLevelMessageListener
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
Sets error handler.- Parameters:
handler
- the error handler- See Also:
-
setRejectMessageListener
Sets reject listener.- Parameters:
listener
- the reject message listener- See Also:
-
setSlowConsumerListener
Sets slow consumer message listener.- Parameters:
slowConsumerListener
- slow consumer listener- See Also:
-
setInSeqNum
- Throws:
IOException
-
setOutSeqNum
- Throws:
IOException
-
getInSeqNum
long getInSeqNum() -
getOutSeqNum
long getOutSeqNum()
-