com.epam.fixengine.session
Class AbstractFIXSession

java.lang.Object
  extended by com.epam.fixengine.session.AbstractFIXSession
All Implemented Interfaces:
FIXSession, ExtendedFIXSession, com.epam.fixengine.session.SessionStateListenSupport
Direct Known Subclasses:
AcceptorFIXSession, InitiatorFIXSession

public abstract class AbstractFIXSession
extends Object
implements ExtendedFIXSession, com.epam.fixengine.session.SessionStateListenSupport

The abstract session implementation. Provides base functional for acceptor and initiator sessions.


Nested Class Summary
protected  class AbstractFIXSession.SessionParametersProxyAdaptorListener
           
 
Field Summary
protected  com.epam.fixengine.session.util.ConfigurationAdaptor configuration
           
protected static boolean DEBUG_ENABLED
           
protected  boolean graceful
           
protected  HandlerChain listener
           
protected static Log log
           
protected  FIXMessageFactory messageFactory
           
protected  Queue<FIXFieldListWithType> queue
           
protected  Object sessionLock
           
protected  SessionParameters sessionParameters
           
protected static boolean TRACE_ENABLED
           
protected  FIXTransport transport
           
 
Fields inherited from interface com.epam.fixengine.FIXSession
DEFAULT_SENDING_OPTIONS, SEND_ASYNC, SEND_SYNC
 
Constructor Summary
AbstractFIXSession(FIXMessageFactory messageFactory, SessionParameters sessionParameters, HandlerChain fixSessionListener)
          Creates the AbstractFIXSession .
 
Method Summary
 void addSessionStateListener(com.epam.fixengine.session.FIXSessionStateListener stateListener)
           
 void checkHasSessionSendOrReceivedTestRequest()
          The method checks if TR send or received.
 void clearQueue()
          Clears output message queue.
protected  void configureStateBeforeReset()
           
abstract  void connect()
          Connects to remote counterparty,
if initiator or accepts incoming connection if acceptor.
 void disconnect(com.epam.fixengine.session.DisconnectReason reasonType, String reasonDescription)
           
protected  void disconnect(com.epam.fixengine.session.DisconnectReason reasonType, String reasonDescription, boolean isGracefull, boolean isForced)
           
protected  void disconnect(com.epam.fixengine.session.DisconnectReason reasonType, String reasonDescription, boolean isGracefull, boolean isForced, boolean continueReading)
           
 void disconnect(String reason)
          Disconnect the session.
protected  void disconnectTestRequestIsLost()
          Disconnect the session if test request doesn't received.
 void dispose()
          Disposes current session, removes its reference from GlobalSessionManager
and frees all allocated resources.
 boolean equals(Object o)
           
 void forcedDisconnect(com.epam.fixengine.session.DisconnectReason reasonType, String reasonDescription, boolean continueReading)
          Gracefully disconnects current session but wait for answer forcedLogoffTimeout.
 Object getAttribute(String key)
          Gets session attribute value.
 boolean getAttributeAsBool(com.epam.fixengine.session.ExtendedFIXSessionAttribute attr)
           
 long getAttributeAsLong(com.epam.fixengine.session.ExtendedFIXSessionAttribute attr)
           
 long getBytesRead()
          Gets read bytes.
 long getBytesSent()
          Gets send bytes.
 com.epam.fixengine.encryption.Encryption getEncryption()
           
 ErrorHandler getErrorHandler()
          Gets session error handler.
 long getEstablished()
          Gets established session timestamp.
 ExtendedFIXSessionListener getExtendedFIXSessionListener()
          Gets extended fix session listener.
 MessageStorage getIncomingMessageStorage()
          Gets incoming message storage.
 com.epam.fixengine.session.DisconnectReason getLastDisconnectReason()
           
 long getLastInMessageTimestamp()
          Gets last received message timestamp.
 long getLastOutMessageTimestamp()
          Gets time when the message is sent
 FIXMessageFactory getMessageFactory()
          Gets message factory.
protected  HandlerChain getMessageHandlers()
          Gets chain of message handlers.
 MessageValidator getMessageValidator()
          Returns message validator.
 long getNoOfInMessages()
          Gets number of received message.
 long getNoOfOutMessages()
          Gets number of sent message.
 MessageStorage getOutgoingMessageStorage()
          Gets outgoing message storage.
 int getQueuedMessagesCount()
           
 RejectMessageListener getRejectMessageListener()
          Gets reject message listener.
 com.epam.fixengine.session.SessionSequenceManager getSequenceManager()
           
 SessionParameters getSessionParameters()
          The returned value is cloned.
 SessionParameters getSessionParametersInstance()
          Gets session parameter instance.
 SessionState getSessionState()
          Returns session state.
 StorageFactory getStorageFactory()
          Gets storage factory
 int hashCode()
           
protected  void initSession()
          Initializes the resources and sends a logon message.
protected  void initSessionInternal()
          Initialize session internal.
protected  boolean isResetSeqNumFlagRequiredForInitLogon()
           
protected  boolean isResetTimeMissed(long lastResetTime)
           
 boolean isStatisticEnabled()
          Shows statistics on or off.
protected  void loadSessionParametersFromFile()
          Load session parameters.
 void markShutdownAsGraceful()
          Marks the session shutdown as gracefully.
 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.
abstract  void reject(String reason)
          Reject incoming connection for acceptor.
 void removeAttribute(com.epam.fixengine.session.ExtendedFIXSessionAttribute attr)
           
 void removeAttribute(String key)
          Removes session attribute.
 void removeLongAttribute(com.epam.fixengine.session.ExtendedFIXSessionAttribute attr)
           
 void removeSessionStateListener(com.epam.fixengine.session.FIXSessionStateListener stateListener)
           
protected  void resetSeqNumIfConfigured()
          Resets seq num.
 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.
protected  void resetTestRequestFlags()
           
protected  void restoreSessionAfterReceivedTestRequest()
          Restore the session if test request is received.
 void restoreSessionParameters()
          Restore session parameters in file.
 void saveSessionParameters()
          Save session parameters to file.
 boolean sendAsIs(FIXFieldList message)
          Convenient method to send out FIX message based on the message type and message content.
 boolean sendAsIs(FIXFieldList message, int options)
          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 type, FIXFieldList content)
          Convenient method to send out FIX message based on the message type and message content.
 boolean sendMessage(String type, FIXFieldList content, int optionMask)
          Convenient method to send out FIX message based on the message type and message content.
 int sendMessageAndGetQueueSize(FIXFieldList message, int optionMask)
          Do the same that FIXSession.sendMessage(FIXFieldList, int) and return queue size.
 int sendMessageAndGetQueueSize(String type, FIXFieldList content, int optionMask)
          Do the same that FIXSession.sendMessage(String, FIXFieldList, int) and return queue size.
 boolean sendMessageOutOfTurn(String type, FIXFieldList message)
          Sends message out of turn.
protected  void sendTestRequest()
          Send test request.
 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 options)
          Convenient method to send out FIX message based on the message type and message content.
 int sendWithChangesAndGetQueueSize(FIXFieldList content, ChangesType allowedChangesType)
           
 int sendWithChangesAndGetQueueSize(FIXFieldList content, ChangesType allowedChangesType, int options)
          Do the same that FIXSession.sendWithChanges(FIXFieldList, ChangesType, int) and return queue size.
 void setAttribute(com.epam.fixengine.session.ExtendedFIXSessionAttribute attr, boolean value)
           
 void setAttribute(com.epam.fixengine.session.ExtendedFIXSessionAttribute attr, long value)
           
 void setAttribute(String key, Object object)
          Sets session attribute.
 void setErrorHandler(ErrorHandler handler)
          Sets error handler.
 void setFIXSessionListener(FIXSessionListener listener)
          Sets FIXSession listener to monitor session status and receive incoming messages.
protected  void setLastDisconnectReason(com.epam.fixengine.session.DisconnectReason reason)
           
 void setOutOfTurnMode(boolean mode)
          Sets OutOf turn mode.
protected  void setPreLoggofSessionState(boolean forced, boolean continueReading)
           
 void setRejectMessageListener(RejectMessageListener listener)
          Sets reject message listener.
 void setSequenceNumbers(int inSeqNum, int outSeqNum)
          Allows user to change sequences numbers for disconnected sessions.
 void setSessionState(SessionState sessionState)
          Sets session state.
 void shutdown(boolean blocking)
          Deprecated. 
 void shutdown(com.epam.fixengine.session.DisconnectReason reason, boolean blocking)
          Shutdown the session.
protected  void startSession()
           
protected  void storeProcessedSeqNumber()
          Store the last processed seq number.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static final Log log

DEBUG_ENABLED

protected static final boolean DEBUG_ENABLED

TRACE_ENABLED

protected static final boolean TRACE_ENABLED

transport

protected FIXTransport transport

queue

protected Queue<FIXFieldListWithType> queue

listener

protected final HandlerChain listener

sessionParameters

protected SessionParameters sessionParameters

messageFactory

protected final FIXMessageFactory messageFactory

graceful

protected boolean graceful

sessionLock

protected final Object sessionLock

configuration

protected final com.epam.fixengine.session.util.ConfigurationAdaptor configuration
Constructor Detail

AbstractFIXSession

public AbstractFIXSession(FIXMessageFactory messageFactory,
                          SessionParameters sessionParameters,
                          HandlerChain fixSessionListener)
Creates the AbstractFIXSession .

Method Detail

getSequenceManager

public com.epam.fixengine.session.SessionSequenceManager getSequenceManager()

getExtendedFIXSessionListener

public ExtendedFIXSessionListener getExtendedFIXSessionListener()
Description copied from interface: ExtendedFIXSession
Gets extended fix session listener.

Specified by:
getExtendedFIXSessionListener in interface ExtendedFIXSession
See Also:
ExtendedFIXSession.getExtendedFIXSessionListener()

getStorageFactory

public StorageFactory getStorageFactory()
Gets storage factory


getRejectMessageListener

public RejectMessageListener getRejectMessageListener()
Description copied from interface: ExtendedFIXSession
Gets reject message listener.

Specified by:
getRejectMessageListener in interface ExtendedFIXSession
Returns:
reject message listener
See Also:
ExtendedFIXSession.getRejectMessageListener()

getErrorHandler

public ErrorHandler getErrorHandler()
Description copied from interface: ExtendedFIXSession
Gets session error handler.

Specified by:
getErrorHandler in interface ExtendedFIXSession
Returns:
error handler
See Also:
ExtendedFIXSession.getErrorHandler()

setErrorHandler

public void setErrorHandler(ErrorHandler handler)
Description copied from interface: FIXSession
Sets error handler.

Specified by:
setErrorHandler in interface FIXSession
Parameters:
handler - the error handler
See Also:
FIXSession.setErrorHandler(com.epam.fixengine.ErrorHandler)

setRejectMessageListener

public void setRejectMessageListener(RejectMessageListener listener)
Description copied from interface: FIXSession
Sets reject message listener.

Specified by:
setRejectMessageListener in interface FIXSession
Parameters:
listener - the reject message listener
See Also:
FIXSession.setRejectMessageListener(com.epam.fixengine.RejectMessageListener)

markShutdownAsGraceful

public void markShutdownAsGraceful()
Description copied from interface: ExtendedFIXSession
Marks the session shutdown as gracefully.

Specified by:
markShutdownAsGraceful in interface ExtendedFIXSession
See Also:
ExtendedFIXSession.markShutdownAsGraceful();

clearQueue

public void clearQueue()
Description copied from interface: ExtendedFIXSession
Clears output message queue.
Method also reject all messages from the queue.
To use this feature, the user should set the RejectMessageListener listener.

Specified by:
clearQueue in interface ExtendedFIXSession
See Also:
ExtendedFIXSession.clearQueue()

getQueuedMessagesCount

public int getQueuedMessagesCount()
Specified by:
getQueuedMessagesCount in interface ExtendedFIXSession

setOutOfTurnMode

public void setOutOfTurnMode(boolean mode)
Description copied from interface: ExtendedFIXSession
Sets OutOf turn mode.

Specified by:
setOutOfTurnMode in interface ExtendedFIXSession
Parameters:
mode - the mode

resetSequenceNumbers

public void resetSequenceNumbers()
                          throws IOException
Description copied from interface: FIXSession
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.

Specified by:
resetSequenceNumbers in interface FIXSession
Throws:
IOException
See Also:
FIXSession.resetSequenceNumbers()

resetSequenceNumbers

public void resetSequenceNumbers(boolean checkGapFillBefore)
                          throws IOException
Description copied from interface: FIXSession
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.

Specified by:
resetSequenceNumbers in interface FIXSession
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
See Also:
FIXSession.resetSequenceNumbers(boolean)

setSequenceNumbers

public void setSequenceNumbers(int inSeqNum,
                               int outSeqNum)
                        throws IOException
Description copied from interface: FIXSession
Allows user to change sequences numbers for disconnected sessions.

Specified by:
setSequenceNumbers in interface FIXSession
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

configureStateBeforeReset

protected void configureStateBeforeReset()
                                  throws IOException
Throws:
IOException

setFIXSessionListener

public void setFIXSessionListener(FIXSessionListener listener)
Description copied from interface: FIXSession
Sets FIXSession listener to monitor session status and receive incoming messages.

Specified by:
setFIXSessionListener in interface FIXSession
Parameters:
listener - the user specified listener
See Also:
FIXSession.setFIXSessionListener(FIXSessionListener)

getOutgoingMessageStorage

public MessageStorage getOutgoingMessageStorage()
Description copied from interface: ExtendedFIXSession
Gets outgoing message storage.

Specified by:
getOutgoingMessageStorage in interface ExtendedFIXSession
Returns:
message storage
See Also:
ExtendedFIXSession.getOutgoingMessageStorage()

getIncomingMessageStorage

public MessageStorage getIncomingMessageStorage()
Description copied from interface: ExtendedFIXSession
Gets incoming message storage.

Specified by:
getIncomingMessageStorage in interface ExtendedFIXSession
Returns:
message storage
See Also:
ExtendedFIXSession.getIncomingMessageStorage()

saveSessionParameters

public void saveSessionParameters()
                           throws IOException
Description copied from interface: ExtendedFIXSession
Save session parameters to file.

Specified by:
saveSessionParameters in interface ExtendedFIXSession
Throws:
IOException - if I/O error occurred
See Also:
ExtendedFIXSession.saveSessionParameters()

restoreSessionParameters

public void restoreSessionParameters()
                              throws IOException
Description copied from interface: ExtendedFIXSession
Restore session parameters in file. Method reset all parameters to default.

Specified by:
restoreSessionParameters in interface ExtendedFIXSession
Throws:
IOException - if I/O error occurred
See Also:
ExtendedFIXSession.restoreSessionParameters()

connect

public abstract void connect()
                      throws IOException
Description copied from interface: FIXSession
Connects to remote counterparty,
if initiator or accepts incoming connection if acceptor.

Specified by:
connect in interface FIXSession
Throws:
IOException - I/O exception if error occurred
See Also:
FIXSession.connect()

reject

public abstract void reject(String reason)
                     throws IOException
Description copied from interface: FIXSession
Reject incoming connection for acceptor.
Not applicable for initiator.

Specified by:
reject in interface FIXSession
Throws:
IOException - I/O exception if error occurred
See Also:
FIXSession.reject(String)

getSessionParametersInstance

public SessionParameters getSessionParametersInstance()
Description copied from interface: ExtendedFIXSession
Gets session parameter instance.

Specified by:
getSessionParametersInstance in interface ExtendedFIXSession
See Also:
ExtendedFIXSession.getSessionParametersInstance()

getMessageFactory

public FIXMessageFactory getMessageFactory()
Description copied from interface: ExtendedFIXSession
Gets message factory.

Specified by:
getMessageFactory in interface ExtendedFIXSession
Returns:
message factory
See Also:
ExtendedFIXSession.getMessageFactory()

getSessionParameters

public SessionParameters getSessionParameters()
The returned value is cloned.

Specified by:
getSessionParameters in interface FIXSession
Returns:
SessionParameters - session parameters
See Also:
FIXSession.getSessionParameters()

getSessionState

public SessionState getSessionState()
Description copied from interface: FIXSession
Returns session state.

Specified by:
getSessionState in interface FIXSession
Returns:
SessionState - session state
See Also:
FIXSession.getSessionState()

setSessionState

public void setSessionState(SessionState sessionState)
Description copied from interface: ExtendedFIXSession
Sets session state.

Specified by:
setSessionState in interface ExtendedFIXSession
Parameters:
sessionState - the new session state
See Also:
ExtendedFIXSession.setSessionState(com.epam.fixengine.SessionState)

isStatisticEnabled

public boolean isStatisticEnabled()
Description copied from interface: ExtendedFIXSession
Shows statistics on or off.

Specified by:
isStatisticEnabled in interface ExtendedFIXSession
Returns:
true is statistic is enabled
See Also:
ExtendedFIXSession.isStatisticEnabled()

getBytesRead

public long getBytesRead()
Description copied from interface: ExtendedFIXSession
Gets read bytes.

Specified by:
getBytesRead in interface ExtendedFIXSession
Returns:
number of read bytes or -1 if statistic is disabled
See Also:
ExtendedFIXSession.getBytesRead()

getEstablished

public long getEstablished()
Description copied from interface: ExtendedFIXSession
Gets established session timestamp.

Specified by:
getEstablished in interface ExtendedFIXSession
Returns:
timestamp
See Also:
ExtendedFIXSession.getEstablished()

getBytesSent

public long getBytesSent()
Description copied from interface: ExtendedFIXSession
Gets send bytes.

Specified by:
getBytesSent in interface ExtendedFIXSession
Returns:
number of send bytes or -1 if statistic is disabled
See Also:
ExtendedFIXSession.getBytesSent()

getNoOfInMessages

public long getNoOfInMessages()
Description copied from interface: ExtendedFIXSession
Gets number of received message.

Specified by:
getNoOfInMessages in interface ExtendedFIXSession
Returns:
number of received message or -1 if statistic is disabled
See Also:
ExtendedFIXSession.getNoOfInMessages()

getNoOfOutMessages

public long getNoOfOutMessages()
Description copied from interface: ExtendedFIXSession
Gets number of sent message.

Specified by:
getNoOfOutMessages in interface ExtendedFIXSession
Returns:
number of sent message or -1 if statistic is disabled
See Also:
ExtendedFIXSession.getNoOfOutMessages()

getLastInMessageTimestamp

public long getLastInMessageTimestamp()
Description copied from interface: ExtendedFIXSession
Gets last received message timestamp.

Specified by:
getLastInMessageTimestamp in interface ExtendedFIXSession
Returns:
timestamp
See Also:
ExtendedFIXSession.getLastInMessageTimestamp()

getLastOutMessageTimestamp

public long getLastOutMessageTimestamp()
Description copied from interface: ExtendedFIXSession
Gets time when the message is sent

Specified by:
getLastOutMessageTimestamp in interface ExtendedFIXSession
Returns:
time when the message is sent or -1 if statistic is disabled
See Also:
ExtendedFIXSession.getLastOutMessageTimestamp()

getMessageHandlers

protected HandlerChain getMessageHandlers()
Gets chain of message handlers.


initSession

protected void initSession()
                    throws IOException
Initializes the resources and sends a logon message.

Throws:
IOException - - if I/O error occurred.

isResetSeqNumFlagRequiredForInitLogon

protected boolean isResetSeqNumFlagRequiredForInitLogon()

resetSeqNumIfConfigured

protected void resetSeqNumIfConfigured()
                                throws IOException
Resets seq num.

This method should call only before session is created.

Throws:
IOException

isResetTimeMissed

protected boolean isResetTimeMissed(long lastResetTime)

initSessionInternal

protected void initSessionInternal()
                            throws IOException
Initialize session internal.

The method is created all session object: in/out storage and pumper/reader, etc.

Throws:
IOException

loadSessionParametersFromFile

protected void loadSessionParametersFromFile()
Load session parameters.

Method load only lastProcessedIncomingSequenceNumber from session properties file.

See Also:
.

startSession

protected void startSession()
                     throws IOException
Throws:
IOException

disconnect

public void disconnect(String reason)
Disconnect the session.
The method sends the logof message, if response is not received during the HBI, shutdown the session.

Specified by:
disconnect in interface FIXSession
Parameters:
reason - the reason, if parameter is not null, the logof message will be send with 58=reason.
See Also:
FIXSession.disconnect(String)

disconnect

public void disconnect(com.epam.fixengine.session.DisconnectReason reasonType,
                       String reasonDescription)
Specified by:
disconnect in interface ExtendedFIXSession

forcedDisconnect

public void forcedDisconnect(com.epam.fixengine.session.DisconnectReason reasonType,
                             String reasonDescription,
                             boolean continueReading)
Description copied from interface: ExtendedFIXSession
Gracefully disconnects current session but wait for answer forcedLogoffTimeout.
Logoff with specified reason will be sent to your counterparty. Session will wait the answer for some period, defined by forcedLogoffTimeout configuration property. Note: This method doesn't guarantee immediate shutdown, since FIX protocol require us to wait for counterparty logoff reply. Note: Use this method if you need to close session in exceptional cases and when there is a chance that counterparty newer answer.

Specified by:
forcedDisconnect in interface ExtendedFIXSession
reasonDescription - the reason
continueReading - if false then reading of incoming messages will be stopped. This can be used for prevent reading of messages with broken sequencing.

disconnect

protected void disconnect(com.epam.fixengine.session.DisconnectReason reasonType,
                          String reasonDescription,
                          boolean isGracefull,
                          boolean isForced)

disconnect

protected void disconnect(com.epam.fixengine.session.DisconnectReason reasonType,
                          String reasonDescription,
                          boolean isGracefull,
                          boolean isForced,
                          boolean continueReading)

shutdown

@Deprecated
public void shutdown(boolean blocking)
Deprecated. 

Description copied from interface: ExtendedFIXSession
Shutdown the session.

Specified by:
shutdown in interface ExtendedFIXSession
Parameters:
blocking - If the parameter is true, the next call of method is blocking.

shutdown

public void shutdown(com.epam.fixengine.session.DisconnectReason reason,
                     boolean blocking)
Shutdown the session. If the parameter blocking is true, the next call of method is blocking.

Specified by:
shutdown in interface ExtendedFIXSession
Parameters:
blocking - the blocking parameter
reason - disconnect reason

storeProcessedSeqNumber

protected void storeProcessedSeqNumber()
Store the last processed seq number.

The method work only when last processed and last incoming seq nums are not equals.


setPreLoggofSessionState

protected void setPreLoggofSessionState(boolean forced,
                                        boolean continueReading)

sendMessage

public boolean sendMessage(String type,
                           FIXFieldList content,
                           int optionMask)
Description copied from interface: FIXSession
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.

Specified by:
sendMessage in interface FIXSession
Parameters:
type - the message type (Tag 35 content)
content - the message content
optionMask - FIXSession.SEND_SYNC or FIXSession.SEND_ASYNC
Returns:
true if message was send immediately, false - message was queued for later sending
See Also:
FIXSession.sendMessage(String, com.epam.fix.message.FIXFieldList)

sendMessageAndGetQueueSize

public int sendMessageAndGetQueueSize(String type,
                                      FIXFieldList content,
                                      int optionMask)
Description copied from interface: ExtendedFIXSession
Do the same that FIXSession.sendMessage(String, FIXFieldList, int) and return queue size.

Specified by:
sendMessageAndGetQueueSize in interface ExtendedFIXSession
Returns:
queue size. 0 if message was send synchronously
See Also:
FIXSession.sendMessage(String, FIXFieldList, int)

sendMessage

public boolean sendMessage(String type,
                           FIXFieldList content)
Description copied from interface: FIXSession
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.

Specified by:
sendMessage in interface FIXSession
Parameters:
type - the message type (Tag 35 content)
content - the message content
Returns:
true if message was send immediately, false - message was queued for later sending

sendAsIs

public boolean sendAsIs(FIXFieldList message,
                        int options)
Description copied from interface: FIXSession
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.

Specified by:
sendAsIs in interface FIXSession
Parameters:
message - the message content
options - FIXSession.SEND_SYNC or FIXSession.SEND_ASYNC
Returns:
true if message was send immediately, false - message was queued for later sending

sendAsIs

public boolean sendAsIs(FIXFieldList message)
Description copied from interface: FIXSession
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.

Specified by:
sendAsIs in interface FIXSession
Parameters:
message - the message content
Returns:
true if message was send immediately, false - message was queued for later sending

sendWithChanges

public boolean sendWithChanges(FIXFieldList content,
                               ChangesType allowedChangesType,
                               int options)
Description copied from interface: FIXSession
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.

Specified by:
sendWithChanges in interface FIXSession
Parameters:
content - the message content
allowedChangesType - the parameter takes the next values:
options - FIXSession.SEND_SYNC or FIXSession.SEND_ASYNC
Returns:
true if message was send immediately, false - message was queued for later sending
See Also:
ChangesType

sendWithChangesAndGetQueueSize

public int sendWithChangesAndGetQueueSize(FIXFieldList content,
                                          ChangesType allowedChangesType,
                                          int options)
Description copied from interface: ExtendedFIXSession
Do the same that FIXSession.sendWithChanges(FIXFieldList, ChangesType, int) and return queue size.

Specified by:
sendWithChangesAndGetQueueSize in interface ExtendedFIXSession
Returns:
queue size. 0 if message was send synchronously
See Also:
FIXSession.sendWithChanges(FIXFieldList, ChangesType, int)

sendWithChanges

public boolean sendWithChanges(FIXFieldList content,
                               ChangesType allowedChangesType)
Description copied from interface: FIXSession
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.

Specified by:
sendWithChanges in interface FIXSession
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
See Also:
ChangesType

sendWithChangesAndGetQueueSize

public int sendWithChangesAndGetQueueSize(FIXFieldList content,
                                          ChangesType allowedChangesType)

prepareMessage

public FIXFieldList prepareMessage(FIXFieldList message,
                                   MessageStructure structure)
                            throws PreparedMessageException
Description copied from interface: FIXSession
Builds FIXFieldList object from FIXFieldList object.

Specified by:
prepareMessage in interface FIXSession
Parameters:
message - FIXFieldList object
structure - message structure
Returns:
FIXFieldList object
Throws:
PreparedMessageException - exception
See Also:
FIXSession.prepareMessage(FIXFieldList, com.epam.fix.message.MessageStructure)

prepareMessage

public FIXFieldList prepareMessage(FIXFieldList message,
                                   String type,
                                   MessageStructure structure)
                            throws PreparedMessageException
Description copied from interface: FIXSession
Builds FIXFieldList object from FIXFieldList object.

Specified by:
prepareMessage in interface FIXSession
Parameters:
message - FIXFieldList object
type - type of the message
structure - message structure
Returns:
FIXFieldList object
Throws:
PreparedMessageException - exception
See Also:
FIXSession.prepareMessage(FIXFieldList, String, com.epam.fix.message.MessageStructure)

prepareMessage

public FIXFieldList prepareMessage(String msgType,
                                   MessageStructure userStructure)
                            throws PreparedMessageException
Description copied from interface: FIXSession
Builds FIXFieldList object with specified type, message structure and prefilled header information

Specified by:
prepareMessage in interface FIXSession
Parameters:
msgType - message type
userStructure - message structure
Returns:
FIXFieldList object
Throws:
PreparedMessageException
See Also:
FIXSession.prepareMessage(String, com.epam.fix.message.MessageStructure)

prepareMessageFromString

public FIXFieldList prepareMessageFromString(byte[] message,
                                             MessageStructure structure)
                                      throws PreparedMessageException
Description copied from interface: FIXSession
Builds FIXFieldList object from String object.

Specified by:
prepareMessageFromString in interface FIXSession
Parameters:
message - message string
structure - message structure object
Returns:
FIXFieldList object
Throws:
PreparedMessageException - exception
See Also:
FIXSession.prepareMessageFromString(byte[], com.epam.fix.message.MessageStructure)

prepareMessageFromString

public FIXFieldList prepareMessageFromString(byte[] message,
                                             String type,
                                             MessageStructure structure)
                                      throws PreparedMessageException
Description copied from interface: FIXSession
Builds FIXFieldList object from String object.

Specified by:
prepareMessageFromString in interface FIXSession
Parameters:
message - message string
type - message type
structure - message structure object
Returns:
FIXFieldList object
Throws:
PreparedMessageException - exception
See Also:
FIXSession.prepareMessageFromString(byte[], String, com.epam.fix.message.MessageStructure)

sendMessage

public boolean sendMessage(FIXFieldList message)
Description copied from interface: FIXSession
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.

Specified by:
sendMessage in interface FIXSession
Parameters:
message - the message
Returns:
true if message was send immediately, false - message was queued for later sending
See Also:
FIXSession.sendMessage(com.epam.fix.message.FIXFieldList)

sendMessage

public boolean sendMessage(FIXFieldList message,
                           int optionMask)
Description copied from interface: FIXSession
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.

Specified by:
sendMessage in interface FIXSession
Parameters:
message - the message
optionMask - FIXSession.SEND_SYNC or FIXSession.SEND_ASYNC
Returns:
true if message was send immediately, false - message was queued for later sending

sendMessageAndGetQueueSize

public int sendMessageAndGetQueueSize(FIXFieldList message,
                                      int optionMask)
Description copied from interface: ExtendedFIXSession
Do the same that FIXSession.sendMessage(FIXFieldList, int) and return queue size.

Specified by:
sendMessageAndGetQueueSize in interface ExtendedFIXSession
Returns:
queue size. 0 if message was send synchronously
See Also:
FIXSession.sendMessage(FIXFieldList, int)

sendMessageOutOfTurn

public boolean sendMessageOutOfTurn(String type,
                                    FIXFieldList message)
Description copied from interface: ExtendedFIXSession
Sends message out of turn.

Specified by:
sendMessageOutOfTurn in interface ExtendedFIXSession
Parameters:
type - the message type
message - the message
Returns:
true if message was send immediately, false - message was queued for later sending
See Also:
FIXSession.sendMessage(String, com.epam.fix.message.FIXFieldList)

getMessageValidator

public MessageValidator getMessageValidator()
Description copied from interface: FIXSession
Returns message validator.

Specified by:
getMessageValidator in interface FIXSession
Returns:
message validator for current session
See Also:
FIXSession.getMessageValidator()

dispose

public void dispose()
Description copied from interface: FIXSession
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.

Specified by:
dispose in interface FIXSession
See Also:
FIXSession.dispose()

sendTestRequest

protected void sendTestRequest()
Send test request.


checkHasSessionSendOrReceivedTestRequest

public void checkHasSessionSendOrReceivedTestRequest()
The method checks if TR send or received.

If session is not received any messages during HB interval the HB will be send and If no response received session will be disconnected;

This is helper method for session task.


disconnectTestRequestIsLost

protected void disconnectTestRequestIsLost()
Disconnect the session if test request doesn't received.


restoreSessionAfterReceivedTestRequest

protected void restoreSessionAfterReceivedTestRequest()
Restore the session if test request is received.


resetTestRequestFlags

protected void resetTestRequestFlags()

setAttribute

public void setAttribute(com.epam.fixengine.session.ExtendedFIXSessionAttribute attr,
                         long value)
Specified by:
setAttribute in interface ExtendedFIXSession

removeAttribute

public void removeAttribute(com.epam.fixengine.session.ExtendedFIXSessionAttribute attr)

removeLongAttribute

public void removeLongAttribute(com.epam.fixengine.session.ExtendedFIXSessionAttribute attr)

getAttributeAsLong

public long getAttributeAsLong(com.epam.fixengine.session.ExtendedFIXSessionAttribute attr)
Specified by:
getAttributeAsLong in interface ExtendedFIXSession

setAttribute

public void setAttribute(com.epam.fixengine.session.ExtendedFIXSessionAttribute attr,
                         boolean value)
Specified by:
setAttribute in interface ExtendedFIXSession

getAttributeAsBool

public boolean getAttributeAsBool(com.epam.fixengine.session.ExtendedFIXSessionAttribute attr)
Specified by:
getAttributeAsBool in interface ExtendedFIXSession

setAttribute

public void setAttribute(String key,
                         Object object)
Description copied from interface: ExtendedFIXSession
Sets session attribute.

Specified by:
setAttribute in interface ExtendedFIXSession
Parameters:
key - the attribute key
object - the attribute value
See Also:
ExtendedFIXSession.setAttribute(String, Object)

getAttribute

public Object getAttribute(String key)
Description copied from interface: ExtendedFIXSession
Gets session attribute value.

Specified by:
getAttribute in interface ExtendedFIXSession
Parameters:
key - the attribute key
Returns:
attribute value
See Also:
ExtendedFIXSession.getAttribute(String)

removeAttribute

public void removeAttribute(String key)
Description copied from interface: ExtendedFIXSession
Removes session attribute.

Specified by:
removeAttribute in interface ExtendedFIXSession
Parameters:
key - the attribute key
See Also:
ExtendedFIXSession.removeAttribute(String)

addSessionStateListener

public void addSessionStateListener(com.epam.fixengine.session.FIXSessionStateListener stateListener)
Specified by:
addSessionStateListener in interface com.epam.fixengine.session.SessionStateListenSupport

removeSessionStateListener

public void removeSessionStateListener(com.epam.fixengine.session.FIXSessionStateListener stateListener)
Specified by:
removeSessionStateListener in interface com.epam.fixengine.session.SessionStateListenSupport

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getEncryption

public com.epam.fixengine.encryption.Encryption getEncryption()
Specified by:
getEncryption in interface ExtendedFIXSession

setLastDisconnectReason

protected void setLastDisconnectReason(com.epam.fixengine.session.DisconnectReason reason)

getLastDisconnectReason

public com.epam.fixengine.session.DisconnectReason getLastDisconnectReason()
Specified by:
getLastDisconnectReason in interface ExtendedFIXSession


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