Package com.btobits.fixengine
Class FIXEngineB2B
java.lang.Object
com.btobits.fixengine.FIXEngineB2B
- All Implemented Interfaces:
FIXEngine
Implementation of interface FIXEngine.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFIXEngineB2B
(Application application, String configFileName, boolean showMonitor) Creates and starts a FIX Engine instance.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
(String configFileName, boolean showMonitor) Creates and starts a FIX Engine instance.FIXEngineB2B
(Properties config, boolean showMonitor) Creates and starts a FIX Engine instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
Closes engine.void
closeEngineSession
(String sessionID) Closes session with specifed ID.void
closeEngineSession
(String sessionID, String reason) Closes session with specifed ID.connectToRemoteFIXEngine
(String connectionString) Establishes connection with remote FIX Engine.connectToRemoteFIXEngine
(String connectionString, int heartBtInt, String senderCompID, String targetCompID, int encryptionType) Establishes connection with remote FIX Engine.connectToRemoteFIXEngine
(String connectionString, int heartBtInt, String senderCompID, String targetCompID, int encryptionType, int startFromSeqNum) Establishes connection with remote FIX Engine.connectToRemoteFIXEngine
(String connectionString, int heartBtInt, String senderCompID, String targetCompID, int encryptionMode, int outgoingSeqNum, int incomingSeqNum) connectToRemoteFIXEngine
(String connectionString, StdHdrParamStruct stdHdrParamStruct, LogonParamStruct logonParamStruct, int outgoingSeqNum) Establishes connection with remote FIX Engine.connectToRemoteFIXEngine
(String connectionString, StdHdrParamStruct stdHdrParamStruct, LogonParamStruct logonParamStruct, int outgoingSeqNum, int incomingSeqNum) Gets FIX Engine's propertiesgetFIXVersionBySessionID
(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.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.getSenderCompIDbySession
(String sessionID) Gets SenderCompID of session with specified ID.getSessionIDbyCompIDs
(String senderCompID, String targetCompID) Gets session ID by senderCompID and targetCompID.getSessionIDBySenderAndTargetCompID2
(String senderCompID, String targetCompID) getSessionIDByTargetCompID2
(String targetCompID) int
Gets number of active sessions for current FIX Engine.getTargetCompIDbySession
(String sessionID) Gets TargetCompID of session with specified 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 right 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
Unregisters application in FIX Engine instance.
-
Field Details
-
FIXAJ_HOME_NAME
- See Also:
-
FIXAJ_HOME_VALUE
- See Also:
-
-
Constructor Details
-
FIXEngineB2B
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
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 Details
-
closeEngine
Closes engine.- Specified by:
closeEngine
in interfaceFIXEngine
- Throws:
Exception
- if the FIX Engine cannot be properly closed.
-
closeEngineSession
Closes session with specifed ID.- Specified by:
closeEngineSession
in interfaceFIXEngine
- Parameters:
sessionID
- closing session ID- Throws:
SessionNotFoundException
- if the session cannot be found or properly closed.
-
closeEngineSession
Closes session with specifed ID.- Specified by:
closeEngineSession
in interfaceFIXEngine
- 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
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 interfaceFIXEngine
- Parameters:
connectionString
- the connection 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 interfaceFIXEngine
- Parameters:
heartBtInt
- the value of Heartbeat interval in seconds, which will be placed in InitialProcess messagesenderCompID
- the SenderCompID, which will be placed in messages headerstargetCompID
- the TargetCompID, which will be placed in messages headersencryptionType
- the type of encryption.- Returns:
- ID of created session
- Throws:
EngineNotFoundException
- if connection cannot be created or logon response 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 interfaceFIXEngine
- Parameters:
heartBtInt
- Value of Heartbeat interval in seconds, which will be placed in InitialProcess messagesenderCompID
- the SenderCompID, which will be placed in messages headerstargetCompID
- the TargetCompID, which will be placed in messages headersencryptionType
- the type of encryption.startFromSeqNum
- the starting outgoing sequence number.- Returns:
- ID of created session
- Throws:
EngineNotFoundException
- if connection cannot be created or logon response 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 interfaceFIXEngine
- Parameters:
stdHdrParamStruct
- structure, which contains Standard Message Header parameterslogonParamStruct
- structure, which contains InitialProcess Message parameters- Returns:
- ID of created session
- Throws:
EngineNotFoundException
- if connection cannot be created or logon response 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
Gets FIX Engine's properties -
getSenderCompIDbySession
Gets SenderCompID of session with specified ID.- Specified by:
getSenderCompIDbySession
in interfaceFIXEngine
- 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 interfaceFIXEngine
- Parameters:
senderCompID
- senderCompIDtargetCompID
- 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
Gets TargetCompID of session with specified ID.- Specified by:
getTargetCompIDbySession
in interfaceFIXEngine
- Parameters:
sessionID
- the session ID string- Throws:
SessionNotFoundException
- if session cannot be found.
-
registerApplication
Registers application in FIX Engine instance.- Specified by:
registerApplication
in interfaceFIXEngine
- 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 interfaceFIXEngine
-
sendMessage
Put FIX message message to queue for sending to remote FIX Engine.- Specified by:
sendMessage
in interfaceFIXEngine
- Parameters:
message
- the message to be sent.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 right now.- Specified by:
sendMessageOutOfTurn
in interfaceFIXEngine
- Parameters:
message
- the message to be sent in FIXMessage formatsessionID
- the ID of session in which message will be sent- Throws:
ApplMessageTransmitException
- if the message cannot be sent to the counterparty.
-
getFIXVersionBySessionID
Gets the FIX Protocol version ID for specified session.- Specified by:
getFIXVersionBySessionID
in interfaceFIXEngine
- 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 retrieved.
-
resetSequenceNumber
Resets SeqNumber to 1 for session with indicated sessionID.- Parameters:
sessionID
- ID of session- Throws:
Exception
-
getHeartbeatIntervalBySessionID
Gets the FIX Protocol version ID for specified session.- Specified by:
getHeartbeatIntervalBySessionID
in interfaceFIXEngine
- Parameters:
sessionID
- the session ID.- Returns:
- the heartbeat interval in seconds.
- Throws:
Exception
- if the heartbeat interval cannot be retrieved.
-
getIncomingSequenceBySessionID
Gets incoming sequence number for session with indicated sessionID.- Specified by:
getIncomingSequenceBySessionID
in interfaceFIXEngine
- Parameters:
sessionID
- the ID of session.- Throws:
Exception
- if the incoming sequence number cannot be retrieved.
-
getOutgoingSequenceBySessionID
Gets outgoing sequence number for session with indicated sessionID.- Specified by:
getOutgoingSequenceBySessionID
in interfaceFIXEngine
- Parameters:
sessionID
- the ID of session.- Throws:
Exception
- if the outgoing sequence number cannot be retrieved.
-
setIncomingSequence4SessionBySessionID
Sets IncomingSequence interval for session with indicated sessionID.- Parameters:
sessionID
- ID of session- Throws:
Exception
-
setOutgoingSequence4SessionBySessionID
Sets OutgoingSequence interval for session with indicated sessionID.- Parameters:
sessionID
- ID of session- Throws:
Exception
-
getSessionIDByTargetCompID2
-
getSessionIDBySenderAndTargetCompID2
-
getMessageFromMessageStore
public FIXMessage getMessageFromMessageStore(MessageDirection messageType, long seqNum, String sessionID) throws Exception Retrieves FIX Message from the Message Storage.- Specified by:
getMessageFromMessageStore
in interfaceFIXEngine
- 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
Checks if session is online.- Specified by:
isSessionActive
in interfaceFIXEngine
- Parameters:
sessionID
- the session ID string.- Returns:
- true if session is online.
- Throws:
Exception
- if session cannot be found.
-
addGlobalEventListener
Description copied from interface:FIXEngine
Adds global event listener for listening all sessions.- Specified by:
addGlobalEventListener
in interfaceFIXEngine
- Parameters:
eventListener
- the event listener implementation.
-
removeGlobalEventListener
Description copied from interface:FIXEngine
Removes global event listener for listening all session.- Specified by:
removeGlobalEventListener
in interfaceFIXEngine
- Parameters:
eventListener
- the event listener implementation.
-
addEventListener
Description copied from interface:FIXEngine
Adds event listener for listening specified session.- Specified by:
addEventListener
in interfaceFIXEngine
- Parameters:
sessionID
- the ID of session, which will be listened.eventListener
- the event listener implementation.
-
removeEventListener
Description copied from interface:FIXEngine
Removes event listener for listening specified session.- Specified by:
removeEventListener
in interfaceFIXEngine
- Parameters:
sessionID
- the ID of session, which will be listened.eventListener
- the event listener implementation.
-
getSessions
-