com.btobits.fixengine
Class FIXEngineB2B

java.lang.Object
  extended by com.btobits.fixengine.FIXEngineB2B
All Implemented Interfaces:
FIXEngine

public class FIXEngineB2B
extends Object
implements FIXEngine

Implementation of interface FIXEngine.


Field Summary
static String FIXAJ_HOME_NAME
           
static String FIXAJ_HOME_VALUE
           
 
Constructor Summary
FIXEngineB2B(Application application, Properties config, boolean showMonitor)
          Creates and starts a FIX Engine instance.
FIXEngineB2B(Application application, Properties config, boolean showMonitor, String homePath)
          Creates and starts a FIX Engine instance.
FIXEngineB2B(Application application, String configFileName, boolean showMonitor)
          Creates and starts a FIX Engine instance.
FIXEngineB2B(Properties config, boolean showMonitor)
          Creates and starts a FIX Engine instance.
FIXEngineB2B(String configFileName, boolean showMonitor)
          Creates and starts a FIX Engine instance.
 
Method Summary
 void addEventListener(String sessionID, EventListener eventListener)
          Adds event listener for listening specified session.
 void addGlobalEventListener(EventListener eventListener)
          Adds global event listener for listening all sessions.
 void closeEngine()
          Closes engine.
 void closeEngineSession(String sessionID)
          Closes session with specifed ID.
 void closeEngineSession(String sessionID, String reason)
          Closes session with specifed ID.
 String connectToRemoteFIXEngine(String connectionString)
          Establishes connection with remote FIX Engine.
 String connectToRemoteFIXEngine(String connectionString, int heartBtInt, String senderCompID, String targetCompID, int encryptionType)
          Establishes connection with remote FIX Engine.
 String connectToRemoteFIXEngine(String connectionString, int heartBtInt, String senderCompID, String targetCompID, int encryptionType, int startFromSeqNum)
          Establishes connection with remote FIX Engine.
 String connectToRemoteFIXEngine(String connectionString, int heartBtInt, String senderCompID, String targetCompID, int encryptionMode, int outgoingSeqNum, int incomingSeqNum)
           
 String connectToRemoteFIXEngine(String connectionString, StdHdrParamStruct stdHdrParamStruct, LogonParamStruct logonParamStruct, int outgoingSeqNum)
          Establishes connection with remote FIX Engine.
 String connectToRemoteFIXEngine(String connectionString, StdHdrParamStruct stdHdrParamStruct, LogonParamStruct logonParamStruct, int outgoingSeqNum, int incomingSeqNum)
           
 Properties getConfig()
          Gets FIX Engine's properies
 FIXVersion getFIXVersionBySessionID(String sessionID)
          Gets the FIX Protocol version ID for specified session.
 int getHeartbeatIntervalBySessionID(String sessionID)
          Gets the FIX Protocol version ID for specified session.
 int getIncomingSequenceBySessionID(String sessionID)
          Gets incoming sequence number for session with indicated sessionID.
 FIXMessage getMessageFromMessageStore(MessageDirection messageType, long seqNum, String sessionID)
          Retrieves FIX Message from the Message Storage.
 int getOutgoingSequenceBySessionID(String sessionID)
          Gets outgoing sequence number for session with indicated sessionID.
 String getSenderCompIDbySession(String sessionID)
          Gets SenderCompID of session with specifed ID.
 String getSessionIDbyCompIDs(String senderCompID, String targetCompID)
          Gets session ID by senderCompID and targetCompID.
 String getSessionIDBySenderAndTargetCompID2(String senderCompID, String targetCompID)
           
 String getSessionIDByTargetCompID2(String targetCompID)
           
 List<ExtendedFIXSession> getSessions()
           
 int getSessionsNumber()
          Gets number of active sessions for current FIX Engine.
 String getTargetCompIDbySession(String sessionID)
          Gets TargetCompID of session with specifed ID.
 boolean isSessionActive(String sessionID)
          Checks if session is online.
 void registerApplication(Application application)
          Registers application in FIX Engine instance.
 boolean removeEventListener(String sessionID, EventListener eventListener)
          Removes event listener for listening specified session.
 boolean removeGlobalEventListener(EventListener eventListener)
          Removes global event listener for listening all session.
 void resetSequenceNumber(String sessionID)
          Resets SeqNumber to 1 for session with indicated sessionID.
 void sendMessage(FIXMessage message, String sessionID)
          Put FIX message message to queue for sending to remote FIX Engine.
 void sendMessageOutOfTurn(FIXMessage message, String sessionID)
          Send FIXMessage to remote FIX Engine rigth now.
 void setIncomingSequence4SessionBySessionID(String sessionID, int inSeq)
          Sets IncomingSequence interval for session with indicated sessionID.
 void setOutgoingSequence4SessionBySessionID(String sessionID, int outSeq)
          Sets OutgoingSequence interval for session with indicated sessionID.
 void unregisterApplication()
          Unregisters application in FIX Engine instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIXAJ_HOME_NAME

public static final String FIXAJ_HOME_NAME
See Also:
Constant Field Values

FIXAJ_HOME_VALUE

public static final String FIXAJ_HOME_VALUE
See Also:
Constant Field Values
Constructor Detail

FIXEngineB2B

public FIXEngineB2B(String configFileName,
                    boolean showMonitor)
             throws FIXEngineInitException
Creates and starts a FIX Engine instance.

Parameters:
configFileName - the name of configuration file.
showMonitor - the flag to show or not sessions browser.
Throws:
FIXEngineInitException - if the FIX Engine cannot be created or started.

FIXEngineB2B

public FIXEngineB2B(Properties config,
                    boolean showMonitor)
             throws FIXEngineInitException
Creates and starts a FIX Engine instance.

Parameters:
config - the configuration properties.
showMonitor - the flag to show or not sessions browser.
Throws:
FIXEngineInitException - if the FIX Engine cannot be created or started.

FIXEngineB2B

public FIXEngineB2B(Application application,
                    String configFileName,
                    boolean showMonitor)
             throws FIXEngineInitException
Creates and starts a FIX Engine instance.

Parameters:
application - the application implementation.
configFileName - the name of configuration file.
showMonitor - the flag to show or not sessions browser.
Throws:
FIXEngineInitException - if the FIX Engine cannot be created or started.

FIXEngineB2B

public FIXEngineB2B(Application application,
                    Properties config,
                    boolean showMonitor)
             throws FIXEngineInitException
Creates and starts a FIX Engine instance.

Parameters:
application - the application implementation.
config - the configuration properties.
showMonitor - the flag to show or not sessions browser.
Throws:
FIXEngineInitException - if the FIX Engine cannot be created or started.

FIXEngineB2B

public FIXEngineB2B(Application application,
                    Properties config,
                    boolean showMonitor,
                    String homePath)
             throws FIXEngineInitException
Creates and starts a FIX Engine instance.

Parameters:
application - the application implementation.
config - the configuration properties.
showMonitor - the flag to show or not sessions browser.
homePath - the absolute path to the FIXAJ installation directory or the relative path to the same directory from the launching directory.
Throws:
FIXEngineInitException
Method Detail

closeEngine

public void closeEngine()
                 throws Exception
Closes engine.

Specified by:
closeEngine in interface FIXEngine
Throws:
Exception - if the FIX Engine cannot be properly closed.

closeEngineSession

public void closeEngineSession(String sessionID)
                        throws SessionNotFoundException
Closes session with specifed ID.

Specified by:
closeEngineSession in interface FIXEngine
Parameters:
sessionID - closing session ID
Throws:
SessionNotFoundException - if the session cannot be found or properly closed.

closeEngineSession

public void closeEngineSession(String sessionID,
                               String reason)
                        throws SessionNotFoundException
Closes session with specifed ID.

Specified by:
closeEngineSession in interface FIXEngine
Parameters:
reason - the reason string that will be sent as text field value (tag=58) of logout message.
Throws:
SessionNotFoundException - if the session cannot be found or properly closed.

connectToRemoteFIXEngine

public String connectToRemoteFIXEngine(String connectionString)
                                throws EngineNotFoundException
Establishes connection with remote FIX Engine.

Connection string must be formatted in the following way:
< protocol > < subprotocol > :// < host > : < port >
< protocol > ::= fix42
< subprotocol > ::= tcp

Specified by:
connectToRemoteFIXEngine in interface FIXEngine
Parameters:
connectionString - the connestion string.
Returns:
ID of created session.
Throws:
EngineNotFoundException - if connection cannot be created or logon respose is not received in pre-configured timeout interval.

connectToRemoteFIXEngine

public String connectToRemoteFIXEngine(String connectionString,
                                       int heartBtInt,
                                       String senderCompID,
                                       String targetCompID,
                                       int encryptionType)
                                throws EngineNotFoundException
Establishes connection with remote FIX Engine. Connection string must be formatted in the following way:
< protocol > < subprotocol > :// < host > : < port >
< protocol > ::= fix42
< subprotocol > ::= tcp

Specified by:
connectToRemoteFIXEngine in interface FIXEngine
Parameters:
heartBtInt - the value of Heartbeat interval in seconds, which will be placed in InitialProcess message
senderCompID - the SenderCompID, which will be placed in messages headers
targetCompID - the TargetCompID, which will be placed in messages headers
encryptionType - the type of encryption.
Returns:
ID of created session
Throws:
EngineNotFoundException - if connection cannot be created or logon respose is not received in pre-configured timeout interval.

connectToRemoteFIXEngine

public String connectToRemoteFIXEngine(String connectionString,
                                       int heartBtInt,
                                       String senderCompID,
                                       String targetCompID,
                                       int encryptionType,
                                       int startFromSeqNum)
                                throws EngineNotFoundException
Establishes connection with remote FIX Engine. Connection string must be formatted in the following way:
< protocol > < subprotocol > :// < host > : < port >
< protocol > ::= fix42
< subprotocol > ::= tcp

Specified by:
connectToRemoteFIXEngine in interface FIXEngine
Parameters:
heartBtInt - Value of Heartbeat interval in seconds, which will be placed in InitialProcess message
senderCompID - the SenderCompID, which will be placed in messages headers
targetCompID - the TargetCompID, which will be placed in messages headers
encryptionType - the type of encryption.
startFromSeqNum - the starting outgoing sequence number.
Returns:
ID of created session
Throws:
EngineNotFoundException - if connection cannot be created or logon respose is not received in pre-configured timeout interval.

connectToRemoteFIXEngine

public String connectToRemoteFIXEngine(String connectionString,
                                       int heartBtInt,
                                       String senderCompID,
                                       String targetCompID,
                                       int encryptionMode,
                                       int outgoingSeqNum,
                                       int incomingSeqNum)
                                throws EngineNotFoundException
Throws:
EngineNotFoundException

connectToRemoteFIXEngine

public String connectToRemoteFIXEngine(String connectionString,
                                       StdHdrParamStruct stdHdrParamStruct,
                                       LogonParamStruct logonParamStruct,
                                       int outgoingSeqNum)
                                throws EngineNotFoundException
Establishes connection with remote FIX Engine.

Specified by:
connectToRemoteFIXEngine in interface FIXEngine
Parameters:
stdHdrParamStruct - structure, which contains Standard Message Header parameters
logonParamStruct - structure, which contains InitialProcess Message parameters
Returns:
ID of created session
Throws:
EngineNotFoundException - if connection cannot be created or logon respose is not received in pre-configured timeout interval.

connectToRemoteFIXEngine

public String connectToRemoteFIXEngine(String connectionString,
                                       StdHdrParamStruct stdHdrParamStruct,
                                       LogonParamStruct logonParamStruct,
                                       int outgoingSeqNum,
                                       int incomingSeqNum)
                                throws EngineNotFoundException
Throws:
EngineNotFoundException

getConfig

public Properties getConfig()
Gets FIX Engine's properies


getSenderCompIDbySession

public String getSenderCompIDbySession(String sessionID)
                                throws SessionNotFoundException
Gets SenderCompID of session with specifed ID.

Specified by:
getSenderCompIDbySession in interface FIXEngine
Parameters:
sessionID - session ID
Throws:
SessionNotFoundException - if session cannot be found.

getSessionIDbyCompIDs

public String getSessionIDbyCompIDs(String senderCompID,
                                    String targetCompID)
                             throws SessionNotFoundException
Gets session ID by senderCompID and targetCompID.

Specified by:
getSessionIDbyCompIDs in interface FIXEngine
Parameters:
senderCompID - senderCompID
targetCompID - targetCompID
Returns:
session ID string
Throws:
SessionNotFoundException - if session cannot be found.

getSessionsNumber

public int getSessionsNumber()
Gets number of active sessions for current FIX Engine.

Returns:
active sessions number

getTargetCompIDbySession

public String getTargetCompIDbySession(String sessionID)
                                throws SessionNotFoundException
Gets TargetCompID of session with specifed ID.

Specified by:
getTargetCompIDbySession in interface FIXEngine
Parameters:
sessionID - the session ID string
Throws:
SessionNotFoundException - if session cannot be found.

registerApplication

public void registerApplication(Application application)
Registers application in FIX Engine instance.

Specified by:
registerApplication in interface FIXEngine
Parameters:
application - the application, which will process application messages from remote FIX Engine.

unregisterApplication

public void unregisterApplication()
Unregisters application in FIX Engine instance.

Specified by:
unregisterApplication in interface FIXEngine

sendMessage

public void sendMessage(FIXMessage message,
                        String sessionID)
                 throws ApplMessageTransmitException
Put FIX message message to queue for sending to remote FIX Engine.

Specified by:
sendMessage in interface FIXEngine
Parameters:
message - the message to be send.
sessionID - the ID of session in which message will be sent.
Throws:
ApplMessageTransmitException - if the message cannot be sent to the counterparty.

sendMessageOutOfTurn

public void sendMessageOutOfTurn(FIXMessage message,
                                 String sessionID)
                          throws ApplMessageTransmitException
Send FIXMessage to remote FIX Engine rigth now.

Specified by:
sendMessageOutOfTurn in interface FIXEngine
Parameters:
message - the message to be send in FIXMessage format
sessionID - the ID of session in which message will be sent
Throws:
ApplMessageTransmitException - if the message cannot be sent to the counterparty.

getFIXVersionBySessionID

public FIXVersion getFIXVersionBySessionID(String sessionID)
                                    throws Exception
Gets the FIX Protocol version ID for specified session.

Specified by:
getFIXVersionBySessionID in interface FIXEngine
Parameters:
sessionID - the session ID.
Returns:
the connection protocol version id string: fix40, fix41, fix42, fix43 or fix44.
Throws:
Exception - if the version cannot be retreived.

resetSequenceNumber

public void resetSequenceNumber(String sessionID)
                         throws Exception
Resets SeqNumber to 1 for session with indicated sessionID.

Parameters:
sessionID - ID of session
Throws:
Exception

getHeartbeatIntervalBySessionID

public int getHeartbeatIntervalBySessionID(String sessionID)
                                    throws Exception
Gets the FIX Protocol version ID for specified session.

Specified by:
getHeartbeatIntervalBySessionID in interface FIXEngine
Parameters:
sessionID - the session ID.
Returns:
the heartbeat interval in seconds.
Throws:
Exception - if the heartbeat interval cannot be retreived.

getIncomingSequenceBySessionID

public int getIncomingSequenceBySessionID(String sessionID)
                                   throws Exception
Gets incoming sequence number for session with indicated sessionID.

Specified by:
getIncomingSequenceBySessionID in interface FIXEngine
Parameters:
sessionID - the ID of session.
Throws:
Exception - if the incoming sequence number cannot be retreived.

getOutgoingSequenceBySessionID

public int getOutgoingSequenceBySessionID(String sessionID)
                                   throws Exception
Gets outgoing sequence number for session with indicated sessionID.

Specified by:
getOutgoingSequenceBySessionID in interface FIXEngine
Parameters:
sessionID - the ID of session.
Throws:
Exception - if the outgoing sequence number cannot be retreived.

setIncomingSequence4SessionBySessionID

public void setIncomingSequence4SessionBySessionID(String sessionID,
                                                   int inSeq)
                                            throws Exception
Sets IncomingSequence interval for session with indicated sessionID.

Parameters:
sessionID - ID of session
Throws:
Exception

setOutgoingSequence4SessionBySessionID

public void setOutgoingSequence4SessionBySessionID(String sessionID,
                                                   int outSeq)
                                            throws Exception
Sets OutgoingSequence interval for session with indicated sessionID.

Parameters:
sessionID - ID of session
Throws:
Exception

getSessionIDByTargetCompID2

public String getSessionIDByTargetCompID2(String targetCompID)

getSessionIDBySenderAndTargetCompID2

public String getSessionIDBySenderAndTargetCompID2(String senderCompID,
                                                   String targetCompID)

getMessageFromMessageStore

public FIXMessage getMessageFromMessageStore(MessageDirection messageType,
                                             long seqNum,
                                             String sessionID)
                                      throws Exception
Retrieves FIX Message from the Message Storage.

Specified by:
getMessageFromMessageStore in interface FIXEngine
Parameters:
messageType - the type of message (1 - incoming, 2 - outgoing)
seqNum - the sequence number of the message.
sessionID - the ID of session, from which the message will be retrieved.
Returns:
the retrieved connection message.
Throws:
Exception - if message cannot be retrieved or parsed.

isSessionActive

public boolean isSessionActive(String sessionID)
                        throws Exception
Checks if session is online.

Specified by:
isSessionActive in interface FIXEngine
Parameters:
sessionID - the session ID string.
Returns:
true if session is online.
Throws:
Exception - if session cannot be found.

addGlobalEventListener

public void addGlobalEventListener(EventListener eventListener)
Description copied from interface: FIXEngine
Adds global event listener for listening all sessions.

Specified by:
addGlobalEventListener in interface FIXEngine
Parameters:
eventListener - the event listener implementation.

removeGlobalEventListener

public boolean removeGlobalEventListener(EventListener eventListener)
Description copied from interface: FIXEngine
Removes global event listener for listening all session.

Specified by:
removeGlobalEventListener in interface FIXEngine
Parameters:
eventListener - the event listener implementation.

addEventListener

public void addEventListener(String sessionID,
                             EventListener eventListener)
Description copied from interface: FIXEngine
Adds event listener for listening specified session.

Specified by:
addEventListener in interface FIXEngine
Parameters:
sessionID - the ID of session, which will be listened.
eventListener - the event listener implementation.

removeEventListener

public boolean removeEventListener(String sessionID,
                                   EventListener eventListener)
Description copied from interface: FIXEngine
Removes event listener for listening specified session.

Specified by:
removeEventListener in interface FIXEngine
Parameters:
sessionID - the ID of session, which will be listened.
eventListener - the event listener implementation.

getSessions

public List<ExtendedFIXSession> getSessions()


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