public class FixLibrary extends GatewayProcess
Libraries can be run in the same process as the engine, or in a different process.
FixLibrary instances are not thread safe and should be run on their own thread.
FixEngine
Modifier and Type | Field and Description |
---|---|
static int |
CURRENT_SEQUENCE |
static int |
NO_MESSAGE_REPLAY |
aeron, errorHandler, fixCounters, monitoringAgent, monitoringFile, NO_CONNECTION_ID, NO_CORRELATION_ID
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the Library.
|
static FixLibrary |
connect(LibraryConfiguration configuration)
Start connecting to an engine.
|
java.lang.String |
currentAeronChannel() |
java.util.List<uk.co.real_logic.artio.ilink.ILink3Connection> |
fixPConnections()
Get a list of the currently active FIXP connections.
|
Reply<java.lang.Long> |
followerFixPSession(uk.co.real_logic.artio.fixp.FixPContext context,
long testTimeoutInMs)
Create a FixPConnection for a FIXP Session from a different Artio instance.
|
Reply<SessionWriter> |
followerSession(uk.co.real_logic.artio.builder.SessionHeaderEncoder headerEncoder,
long timeoutInMs)
Create a SessionWriter for a Session from a different Artio instance.
|
java.util.List<uk.co.real_logic.artio.ilink.ILink3Connection> |
iLink3Sessions()
Deprecated.
|
Reply<uk.co.real_logic.artio.ilink.ILink3Connection> |
initiate(uk.co.real_logic.artio.ilink.ILink3ConnectionConfiguration configuration)
Initiate an ILink3 connection.
|
Reply<Session> |
initiate(SessionConfiguration configuration)
Initiate a FIX session.
|
boolean |
isAtEndOfDay() |
boolean |
isClosed() |
boolean |
isConnected()
Check if the library is connected to an engine.
|
int |
libraryId()
Get the identifier of the library.
|
java.util.List<Session> |
pendingInitiatorSessions()
Get a list of the initiator sessions that are currently pending.
|
int |
poll(int fragmentLimit)
Poll the library all of its component sessions to process any messages
and events that have received from or should be sent to the engine.
|
void |
readMetaData(long sessionId,
MetadataHandler handler)
Read the meta data associated with a session.
|
Reply<uk.co.real_logic.artio.messages.SessionReplyStatus> |
releaseToGateway(Session session,
long timeoutInMs)
Release this session object to the gateway to manage.
|
Reply<uk.co.real_logic.artio.messages.SessionReplyStatus> |
requestSession(long sessionId,
int resendFromSequenceNumber,
int resendFromSequenceIndex,
long timeoutInMs)
Request a session be acquired from the Gateway.
|
java.util.List<Session> |
sessions()
Get a list of the currently active sessions.
|
SessionWriter |
sessionWriter(long sessionId,
long connectionId,
int sequenceIndex)
Creates a new SessionWriter for a specified session.
|
protected boolean |
shouldRethrowExceptionInErrorHandler() |
Reply<uk.co.real_logic.artio.messages.MetaDataStatus> |
writeMetaData(long sessionId,
int metaDataUpdateOffset,
org.agrona.DirectBuffer buffer,
int offset,
int length)
Write meta data associated with a session.
|
conductorAgent, configureAeronContext, init, initAeron, initMonitoring, initMonitoringAgent
public static final int NO_MESSAGE_REPLAY
public static final int CURRENT_SEQUENCE
public static FixLibrary connect(LibraryConfiguration configuration)
poll(int)
on a regular duty cycle until the connection completes.
isConnected()
can be polled in order to determine whether library is connected. Also the
LibraryConnectHandler.onConnect(FixLibrary)
method will be invoked.configuration
- the configuration for this library instance.FixGatewayException
- if there's an error connecting to the FIX Gateway.public int poll(int fragmentLimit)
fragmentLimit
- the maximum number of events to read from the engine.public boolean isConnected()
Note that this refers to whether a library is connected to a FIX Engine, not whether of its sessions are connected.
Session.isConnected()
,
FixEngine
public boolean isAtEndOfDay()
public boolean isClosed()
public int libraryId()
public java.util.List<Session> sessions()
Note: the list is unmodifiable.
public java.util.List<Session> pendingInitiatorSessions()
sessions()
list.
Note: the list is unmodifiable.
public void close()
close
in interface java.lang.AutoCloseable
close
in class GatewayProcess
public Reply<Session> initiate(SessionConfiguration configuration)
configuration
- the configuration to use for the session.IllegalStateException
if you're trying to initiate two sessions at the same time or if there's a timeout talking to
the FixEngine
.
This probably indicates that there's a problem in your code or that your engine isn't running.
FixGatewayException
if you're unable to connect to the accepting gateway.
This probably indicates a configuration problem related to the external gateway.LibraryUtil.initiate(FixLibrary, SessionConfiguration, int, IdleStrategy)
public Reply<uk.co.real_logic.artio.messages.SessionReplyStatus> releaseToGateway(Session session, long timeoutInMs)
SessionReplyStatus.OK
.
Similar to initiate(SessionConfiguration)
this is a non-blocking operation that
returns a reply object that indicates what has happened to its result.session
- the session to releasetimeoutInMs
- the timeout for this operationpublic Reply<uk.co.real_logic.artio.messages.SessionReplyStatus> requestSession(long sessionId, int resendFromSequenceNumber, int resendFromSequenceIndex, long timeoutInMs)
LibraryReply
object.
If this session is being managed by
the gateway then your SessionAcquireHandler
will receive a callback
and the reply will be SessionReplyStatus.OK
. You may also receive the reply of
SessionReplyStatus.SEQUENCE_NUMBER_TOO_HIGH
if the sequence number you have passed in
is higher than the current sequence number known by the engine. This may happen to a sequence reset.
In this case you will still get the callback to the SessionAcquireHandler
but won't get a
replay on any messages. You will also get a callback on the SessionAcquireHandler
in the
SessionReplyStatus.MISSING_MESSAGES
and
SessionReplyStatus.INVALID_CONFIGURATION_NOT_LOGGING_MESSAGES
case but you won't necessarily get the
requested replay of messages.
If another library has acquired the session then this method will return
SessionReplyStatus.OTHER_SESSION_OWNER
. If the connection id refers
to an unknown session then the method returns SessionReplyStatus.UNKNOWN_SESSION
.
If this library instance is unknown to the gateway, for example if its heartbeating
mechanism has timed out due to poll(int)
not being called often enough.
If you request a session that exists in the engine but which is not connected then an offline session will be
returned. This is a session whose state is disconnected and has no connection id, connectedHost or connectedPort.sessionId
- the id of the session to acquire.resendFromSequenceNumber
- the last received message sequence number
that you know about. You will get a stream
of messages replayed to you from
resendFromSequenceNumber
to the latest message sequence number.
If you don't care about message replay then
use NO_MESSAGE_REPLAY
as the parameter.resendFromSequenceIndex
- the index of the sequence within which the resendFromSequenceNumber
refers. if you wish to use the curren sequence (ie all messages since the latest logon
then you can use CURRENT_SEQUENCE
.If you don't care about message replay
then use NO_MESSAGE_REPLAY
as the parameter.timeoutInMs
- the timeout for this operationpublic SessionWriter sessionWriter(long sessionId, long connectionId, int sequenceIndex)
SessionProxy
would be hooked so
writing messages outbound on a normal Session object won't work.
Messages written using this writer won't update the sent sequence number of any corresponding Session object.
This is designed to support the intended use-case of hooking the session proxy.sessionId
- the id of the session to use.connectionId
- the id of the connection to use.sequenceIndex
- the sequence index that the SessionWriter should start at.public Reply<SessionWriter> followerSession(uk.co.real_logic.artio.builder.SessionHeaderEncoder headerEncoder, long timeoutInMs)
followerFixPSession(FixPContext, long)
.headerEncoder
- the message header that contains fields that identify the Session. You could set the
senderCompId and targetCompId on this header for example if those are the fields used to
identify your session.timeoutInMs
- the timeout required for this operation.Reply
that will eventually contain the SessionWriter
.public Reply<java.lang.Long> followerFixPSession(uk.co.real_logic.artio.fixp.FixPContext context, long testTimeoutInMs)
followerSession(SessionHeaderEncoder, long)
.context
- the context that uniquely identifies the connectiontestTimeoutInMs
- the timeout required for this operation.requestSession(long, int, int, long)
.java.lang.IllegalArgumentException
- if the FixPProtocol
of the context is
different to the established protocol within the library.public Reply<uk.co.real_logic.artio.messages.MetaDataStatus> writeMetaData(long sessionId, int metaDataUpdateOffset, org.agrona.DirectBuffer buffer, int offset, int length)
metaDataOffset
position within the metadata buffer
or after metaDataOffset + length
will be left as previous. When i
This is an asynchronous operation and the returned reply object should be checked for completion.sessionId
- the session id of the session that meta data is written to.metaDataUpdateOffset
- the offset within the session's metadata buffer. 0
should be used for
initialization.buffer
- the buffer where the meta data to be written is stored.offset
- the offset within the bufferlength
- the length of the data within the buffer.public void readMetaData(long sessionId, MetadataHandler handler)
sessionId
- the id of the session that meta data is read from.handler
- the callback that has the returned metadata.public java.lang.String currentAeronChannel()
public Reply<uk.co.real_logic.artio.ilink.ILink3Connection> initiate(uk.co.real_logic.artio.ilink.ILink3ConnectionConfiguration configuration)
configuration
- the configuration for this Session.@Deprecated public java.util.List<uk.co.real_logic.artio.ilink.ILink3Connection> iLink3Sessions()
Note: the list is unmodifiable.
This method has been deprecated and will be replaced by fixPConnections()
it will continue to work
until then.
public java.util.List<uk.co.real_logic.artio.ilink.ILink3Connection> fixPConnections()
Note: the list is unmodifiable.
protected boolean shouldRethrowExceptionInErrorHandler()
shouldRethrowExceptionInErrorHandler
in class GatewayProcess
Copyright © 2015-2022 Real Logic Limited. All Rights Reserved.