com.epam.fixengine
Interface FIXSession

All Known Subinterfaces:
ExtendedFIXSession, ScheduledFIXSession
All Known Implementing Classes:
AbstractFIXSession, AcceptorFIXSession, BackupFIXSession, 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
static int DEFAULT_SENDING_OPTIONS
           
static int SEND_ASYNC
          ASYNC - Enqueue the message before sending as opposed to sending immediately from calling thread.
static int SEND_SYNC
          FORCE_SYNC - Send the message synchronously.
 
Method Summary
 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.
 MessageValidator getMessageValidator()
          Returns message validator.
 SessionParameters getSessionParameters()
          Returns the cloned session connection parameters instance.
 SessionState getSessionState()
          Returns session state.
 FIXFieldList prepareMessage(FIXFieldList message, MessageStructure structure)
          Builds FIXFieldList object from FIXFieldList object.
 FIXFieldList prepareMessage(FIXFieldList message, String type, MessageStructure structure)
          Builds FIXFieldList object from FIXFieldList object.
 FIXFieldList prepareMessage(String msgType, MessageStructure userStructure)
          Builds FIXFieldList object with specified type, message structure and prefilled header information
 FIXFieldList prepareMessageFromString(byte[] message, MessageStructure structure)
          Builds FIXFieldList object from String object.
 FIXFieldList prepareMessageFromString(byte[] message, String type, MessageStructure structure)
          Builds FIXFieldList object from String object.
 void reject(String reason)
          Reject incoming connection for acceptor.
 void resetSequenceNumbers()
          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 setRejectMessageListener(RejectMessageListener listener)
          Sets reject message listener.
 void setSequenceNumbers(int inSeqNum, int outSeqNum)
          Allows user to change sequences numbers for disconnected sessions.
 

Field Detail

SEND_ASYNC

static final int SEND_ASYNC
ASYNC - Enqueue the message before sending as opposed to sending immediately from calling thread.

See Also:
Constant Field Values

SEND_SYNC

static final int SEND_SYNC
FORCE_SYNC - Send the message synchronously.

See Also:
Constant Field Values

DEFAULT_SENDING_OPTIONS

static final int DEFAULT_SENDING_OPTIONS
See Also:
Constant Field Values
Method Detail

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(int inSeqNum,
                        int 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

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:
ChangesType

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:
ChangesType

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

setFIXSessionListener

void setFIXSessionListener(FIXSessionListener listener)
Sets FIXSession listener to monitor session status and receive incoming messages.

Parameters:
listener - the user specified listener

setErrorHandler

void setErrorHandler(ErrorHandler handler)
Sets error handler.

Parameters:
handler - the error handler
See Also:
ErrorHandler

setRejectMessageListener

void setRejectMessageListener(RejectMessageListener listener)
Sets reject message listener.

Parameters:
listener - the reject message listener
See Also:
RejectMessageListener


Copyright © 2000-2014 EPAM Systems. All Rights Reserved.