public class Subscription
extends java.lang.Object
implements java.lang.AutoCloseable
Image for a stream of messages from publishers on
a given channel and streamId pair. Images are aggregated under a Subscription.
Subscriptions are created via an Aeron object, and received messages are delivered
to the FragmentHandler.
By default fragmented messages are not reassembled before delivery. If an application must
receive whole messages, whether or not they were fragmented, then the Subscriber
should be created with a FragmentAssembler or a custom implementation.
It is an application's responsibility to poll(io.aeron.logbuffer.FragmentHandler, int) the Subscription for new messages.
Note:Subscriptions are not threadsafe and should not be shared between subscribers.| Modifier and Type | Field and Description |
|---|---|
protected AvailableImageHandler |
availableImageHandler |
protected java.lang.String |
channel |
protected io.aeron.ClientConductor |
clientConductor |
protected static Image[] |
EMPTY_ARRAY |
protected Image[] |
images |
protected boolean |
isClosed |
protected long |
p1 |
protected long |
p10 |
protected long |
p11 |
protected long |
p12 |
protected long |
p13 |
protected long |
p14 |
protected long |
p15 |
protected long |
p16 |
protected long |
p17 |
protected long |
p18 |
protected long |
p19 |
protected long |
p2 |
protected long |
p20 |
protected long |
p21 |
protected long |
p22 |
protected long |
p23 |
protected long |
p24 |
protected long |
p25 |
protected long |
p26 |
protected long |
p27 |
protected long |
p28 |
protected long |
p29 |
protected long |
p3 |
protected long |
p30 |
protected long |
p4 |
protected long |
p5 |
protected long |
p6 |
protected long |
p7 |
protected long |
p8 |
protected long |
p9 |
protected long |
registrationId |
protected int |
roundRobinIndex |
protected int |
streamId |
protected UnavailableImageHandler |
unavailableImageHandler |
| Modifier and Type | Method and Description |
|---|---|
AvailableImageHandler |
availableImageHandler()
Callback used to indicate when an
Image becomes available under this Subscription. |
long |
blockPoll(BlockHandler blockHandler,
int blockLengthLimit)
Poll the
Images under the subscription for available message fragments in blocks. |
java.lang.String |
channel()
Media address for delivery to the channel.
|
void |
close()
Close the Subscription so that associated
Images can be released. |
int |
controlledPoll(ControlledFragmentHandler fragmentHandler,
int fragmentLimit)
Poll in a controlled manner the
Images under the subscription for available message fragments. |
void |
forEachImage(java.util.function.Consumer<Image> imageConsumer)
Iterate over the
Images for this subscription. |
Image |
getImage(int index)
Get the image at the given index from the images array.
|
boolean |
hasNoImages()
Has the subscription currently no images connected to it?
|
Image |
imageBySessionId(int sessionId)
Return the
Image associated with the given sessionId. |
int |
imageCount()
Count of images connected to this subscription.
|
java.util.List<Image> |
images()
Get a
List of active Images that match this subscription. |
boolean |
isClosed()
Has this object been closed and should no longer be used?
|
int |
poll(FragmentHandler fragmentHandler,
int fragmentLimit)
Poll the
Images under the subscription for available message fragments. |
long |
rawPoll(RawBlockHandler rawBlockHandler,
int blockLengthLimit)
Poll the
Images under the subscription for available message fragments in blocks. |
long |
registrationId()
Return the registration id used to register this Publication with the media driver.
|
int |
streamId()
Stream identity for scoping within the channel media address.
|
UnavailableImageHandler |
unavailableImageHandler()
Callback used to indicate when an
Image goes unavailable under this Subscription. |
protected long p16
protected long p17
protected long p18
protected long p19
protected long p20
protected long p21
protected long p22
protected long p23
protected long p24
protected long p25
protected long p26
protected long p27
protected long p28
protected long p29
protected long p30
protected static final Image[] EMPTY_ARRAY
protected final long registrationId
protected int roundRobinIndex
protected final int streamId
protected volatile boolean isClosed
protected volatile Image[] images
protected final io.aeron.ClientConductor clientConductor
protected final java.lang.String channel
protected final AvailableImageHandler availableImageHandler
protected final UnavailableImageHandler unavailableImageHandler
protected long p1
protected long p2
protected long p3
protected long p4
protected long p5
protected long p6
protected long p7
protected long p8
protected long p9
protected long p10
protected long p11
protected long p12
protected long p13
protected long p14
protected long p15
public java.lang.String channel()
public int streamId()
public long registrationId()
public AvailableImageHandler availableImageHandler()
Image becomes available under this Subscription.Image becomes available under this Subscription.public UnavailableImageHandler unavailableImageHandler()
Image goes unavailable under this Subscription.Image goes unavailable under this Subscription.public int poll(FragmentHandler fragmentHandler, int fragmentLimit)
Images under the subscription for available message fragments.
Each fragment read will be a whole message if it is under MTU length. If larger than MTU then it will come
as a series of fragments ordered within a session.
To assemble messages that span multiple fragments then use FragmentAssembler.fragmentHandler - callback for handling each message fragment as it is read.fragmentLimit - number of message fragments to limit for the poll operation across multiple Images.public int controlledPoll(ControlledFragmentHandler fragmentHandler, int fragmentLimit)
Images under the subscription for available message fragments.
Control is applied to fragments in the stream. If more fragments can be read on another stream
they will even if BREAK or ABORT is returned from the fragment handler.
Each fragment read will be a whole message if it is under MTU length. If larger than MTU then it will come
as a series of fragments ordered within a session.
To assemble messages that span multiple fragments then use ControlledFragmentAssembler.fragmentHandler - callback for handling each message fragment as it is read.fragmentLimit - number of message fragments to limit for the poll operation across multiple Images.ControlledFragmentHandlerpublic long blockPoll(BlockHandler blockHandler, int blockLengthLimit)
Images under the subscription for available message fragments in blocks.
This method is useful for operations like bulk archiving and messaging indexing.public long rawPoll(RawBlockHandler rawBlockHandler, int blockLengthLimit)
Images under the subscription for available message fragments in blocks.
This method is useful for operations like bulk archiving a stream to file.public boolean hasNoImages()
public int imageCount()
public Image imageBySessionId(int sessionId)
Image associated with the given sessionId.sessionId - associated with the Image.public java.util.List<Image> images()
List of active Images that match this subscription.List of active Images that match this subscription.public void forEachImage(java.util.function.Consumer<Image> imageConsumer)
Images for this subscription.imageConsumer - to handle each Image.public Image getImage(int index)
index - in the arraypublic void close()
Images can be released.
This method is idempotent.close in interface java.lang.AutoCloseablepublic boolean isClosed()
Copyright © 2014-2017 Real Logic Ltd. All Rights Reserved.