public class FIXConnection extends Object implements Closeable
Constructor and Description |
---|
FIXConnection(Clock clock,
SocketChannel channel,
FIXConfig config,
FIXMessageListener listener,
FIXConnectionStatusListener statusListener)
Create a connection.
|
FIXConnection(SocketChannel channel,
FIXConfig config,
FIXMessageListener listener,
FIXConnectionStatusListener statusListener)
Create a connection.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the underlying socket channel.
|
FIXMessage |
create()
Create a message container.
|
SocketChannel |
getChannel()
Get the underlying socket channel.
|
CharSequence |
getCurrentTimestamp()
Get the current timestamp.
|
long |
getIncomingMsgSeqNum()
Get the next incoming MsgSeqNum(34).
|
long |
getOutgoingMsgSeqNum()
Get the next outgoing MsgSeqNum(34).
|
String |
getSenderCompID()
Get the SenderCompID(49).
|
String |
getTargetCompID()
Get the TargetCompID(56).
|
void |
keepAlive()
Keep this connection alive.
|
void |
prepare(FIXMessage message,
char msgType)
Prepare a message.
|
void |
prepare(FIXMessage message,
CharSequence msgType)
Prepare a message.
|
int |
receive()
Receive data from the underlying socket channel.
|
void |
send(FIXMessage message)
Send a message.
|
void |
sendLogon(boolean resetSeqNum)
Send a Logon(A) message.
|
void |
sendLogout()
Send a Logout(5) message.
|
void |
sendLogout(CharSequence text)
Send a Logout(5) message.
|
void |
sendReject(long refSeqNum,
long sessionRejectReason,
CharSequence text)
Send a Reject(3) message.
|
void |
update(FIXMessage message)
Update a message.
|
void |
updateCompID(FIXMessage message)
Update SenderCompID(49) and TargetCompID(56).
|
void |
updateCurrentTimestamp()
Update the current timestamp.
|
public FIXConnection(Clock clock, SocketChannel channel, FIXConfig config, FIXMessageListener listener, FIXConnectionStatusListener statusListener)
clock
- the clockchannel
- the underlying socket channelconfig
- the connection configurationlistener
- the inbound message listenerstatusListener
- the inbound status event listenerpublic FIXConnection(SocketChannel channel, FIXConfig config, FIXMessageListener listener, FIXConnectionStatusListener statusListener)
channel
- the underlying socket channelconfig
- the connection configurationlistener
- the inbound message listenerstatusListener
- the inbound status event listenerpublic SocketChannel getChannel()
public long getIncomingMsgSeqNum()
public long getOutgoingMsgSeqNum()
public String getSenderCompID()
public String getTargetCompID()
public FIXMessage create()
public void prepare(FIXMessage message, char msgType)
Prepare a message. When preparing a message, the following mandatory fields are added:
message
- a messagemsgType
- the MsgType(35)public void prepare(FIXMessage message, CharSequence msgType)
Prepare a message.
message
- a messagemsgType
- the MsgType(35)prepare(FIXMessage, char)
public void update(FIXMessage message)
Update a message. When updating a message, the following mandatory fields are updated:
message
- a messageNullPointerException
- if MsgSeqNum(34) or SendingTime(52) is
not foundpublic void updateCompID(FIXMessage message)
message
- a messageNullPointerException
- if SenderCompID(49) or TargetCompID(56)
is not foundpublic void updateCurrentTimestamp()
Update the current timestamp. The current timestamp is used for the following purposes:
public CharSequence getCurrentTimestamp()
public void keepAlive() throws IOException
If the duration indicated by HeartBtInt(108) has passed since sending a message, send a Heartbeat(0) message.
If the duration indicated by HeartBtInt(108) amended with a reasonable transmission time has passed since receiving a message, send a TestRequest(1) message.
If a TestRequest(1) message has been sent and no data has been received within the duration indicated by HeartBtInt(108) amended with a reasonable transmission time, trigger a status event indicating heartbeat timeout.
IOException
- if an I/O error occurspublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
- if an I/O error occurspublic int receive() throws IOException
IOException
- if an I/O error occurspublic void send(FIXMessage message) throws IOException
message
- a messageIOException
- if an I/O error occurspublic void sendReject(long refSeqNum, long sessionRejectReason, CharSequence text) throws IOException
refSeqNum
- the RefSeqNum(45)sessionRejectReason
- the SessionRejectReason(373)text
- the Text(58)IOException
- if an I/O error occurspublic void sendLogout() throws IOException
IOException
- if an I/O error occurspublic void sendLogout(CharSequence text) throws IOException
text
- the Text(58)IOException
- if an I/O error occurspublic void sendLogon(boolean resetSeqNum) throws IOException
resetSeqNum
- if true set ResetSeqNumFlag(141) to true, otherwise
omit ResetSeqNumFlag(141)IOException
- if an I/O error occursCopyright © 2021. All rights reserved.