public final class Aeron
extends java.lang.Object
implements java.lang.AutoCloseable
Publications and Subscriptions.
Use an Aeron.Context to configure the Aeron object.
A client application requires only one Aeron object per Media Driver.| Modifier and Type | Class and Description |
|---|---|
static class |
Aeron.Context
This class provides configuration for the
Aeron class via the connect(Aeron.Context)
method and its overloads. |
| Modifier and Type | Field and Description |
|---|---|
static org.agrona.ErrorHandler |
DEFAULT_ERROR_HANDLER
The Default handler for Aeron runtime exceptions.
|
static long |
IDLE_SLEEP_NS
Duration in nanoseconds for which the client conductor will sleep between duty cycles.
|
static long |
INTER_SERVICE_TIMEOUT_NS
Default interval that if exceeded between duty cycles the conductor will consider itself a zombie and suicide.
|
static long |
KEEPALIVE_INTERVAL_NS
Default interval between sending keepalive control messages to the driver.
|
static long |
PUBLICATION_CONNECTION_TIMEOUT_MS
Timeout after which if no status messages have been received then a publication is considered not connected.
|
| Modifier and Type | Method and Description |
|---|---|
ExclusivePublication |
addExclusivePublication(java.lang.String channel,
int streamId)
Add an
ExclusivePublication for publishing messages to subscribers from a single thread. |
Publication |
addPublication(java.lang.String channel,
int streamId)
Add a
Publication for publishing messages to subscribers. |
Subscription |
addSubscription(java.lang.String channel,
int streamId)
Add a new
Subscription for subscribing to messages from publishers. |
Subscription |
addSubscription(java.lang.String channel,
int streamId,
AvailableImageHandler availableImageHandler,
UnavailableImageHandler unavailableImageHandler)
Add a new
Subscription for subscribing to messages from publishers. |
void |
close()
Clean up and release all Aeron internal resources and shutdown threads.
|
static Aeron |
connect()
Create an Aeron instance and connect to the media driver with a default
Aeron.Context. |
static Aeron |
connect(Aeron.Context ctx)
Create an Aeron instance and connect to the media driver.
|
org.agrona.concurrent.status.CountersReader |
countersReader()
Create and return a
CountersReader for the Aeron media driver counters. |
long |
nextCorrelationId()
Generate the next correlation id that is unique for the connected Media Driver.
|
public static final org.agrona.ErrorHandler DEFAULT_ERROR_HANDLER
DriverTimeoutException is encountered, this handler will
exit the program.
The error handler can be overridden by supplying an Aeron.Context with a custom handler.Aeron.Context.errorHandler(ErrorHandler)public static final long IDLE_SLEEP_NS
public static final long KEEPALIVE_INTERVAL_NS
public static final long INTER_SERVICE_TIMEOUT_NS
public static final long PUBLICATION_CONNECTION_TIMEOUT_MS
public static Aeron connect()
Aeron.Context.
Threads required for interacting with the media driver are created and managed within the Aeron instance.Aeron instance connected to the Media Driver.public static Aeron connect(Aeron.Context ctx)
Aeron.Context.close() method
will be called on the passed context.ctx - for configuration of the client.Aeron instance connected to the Media Driver.public void close()
close in interface java.lang.AutoCloseablepublic Publication addPublication(java.lang.String channel, int streamId)
Publication for publishing messages to subscribers.channel - for receiving the messages known to the media layer.streamId - within the channel scope.public ExclusivePublication addExclusivePublication(java.lang.String channel, int streamId)
ExclusivePublication for publishing messages to subscribers from a single thread.channel - for receiving the messages known to the media layer.streamId - within the channel scope.public Subscription addSubscription(java.lang.String channel, int streamId)
Subscription for subscribing to messages from publishers.
The method will set up the Subscription to use the
Aeron.Context.availableImageHandler(AvailableImageHandler) and
Aeron.Context.unavailableImageHandler(UnavailableImageHandler) from the Aeron.Context.channel - for receiving the messages known to the media layer.streamId - within the channel scope.Subscription for the channel and streamId pair.public Subscription addSubscription(java.lang.String channel, int streamId, AvailableImageHandler availableImageHandler, UnavailableImageHandler unavailableImageHandler)
Subscription for subscribing to messages from publishers.
This method will override the default handlers from the Aeron.Context, i.e.
Aeron.Context.availableImageHandler(AvailableImageHandler) and
Aeron.Context.unavailableImageHandler(UnavailableImageHandler). Null values are valid and will
result in no action being taken.channel - for receiving the messages known to the media layer.streamId - within the channel scope.availableImageHandler - called when Images become available for consumption. Null is valid if no
action is to be taken.unavailableImageHandler - called when Images go unavailable for consumption. Null is valid if no
action is to be taken.Subscription for the channel and streamId pair.public long nextCorrelationId()
public org.agrona.concurrent.status.CountersReader countersReader()
CountersReader for the Aeron media driver counters.CountersReader for the Aeron media driver in use.Copyright © 2014-2017 Real Logic Ltd. All Rights Reserved.