V
- the type of the topic valuespublic interface NamedTopic<V> extends NamedCollection
A topic may have any number of publishers
or subscribers
.
Subscriber
s subscribe directly to the topic or subscribe to a logical subscriber group
of the topic.
Each published value to a topic is delivered to all direct topic Subscriber
s and
each subscriber group of the topic. Each value of a subscriber group is only consumed by one subscriber group member
.
Thus each subscriber group in effect behaves like a queue over the topic data.
Once published
, a value will be retained by the topic until it has either
expired or has been received
by all subscriber group(s)
and direct topic Subscriber
(s) which were registered prior to it being published.
The ordering of values within the topic is dependent on the Publisher.OrderBy
option.
Subscriber Group Lifecycle
A subscriber group is created either at configuration time or dynamically.
A subscriber-group child element of a topic-mapping element in a cache configuration file statically
configures a subscriber group when the topic is created, ensuring all values published to the
topic are also delivered to the statically configured subscriber group.
A subscriber group is created dynamically when a createSubscriber call
specifies a
subscriber group name using the option Subscriber.Name.of(String)
and the subscriber group does not exist on the NamedTopic
.
One must actively manage a NamedTopic's logical subscriber groups
since their life span
is independent of their active Subscriber
membership.
destroySubscriberGroup(String)
releases storage and stops accumulating topic values for a subscriber group.
To release storage resources for unconsumed values for a direct topic Subscriber
, it is sufficient to ensure it is closed
.
Both topic Publisher
and Subscriber
can be defined with the try-with-resource pattern to ensure their resources are
closed when no longer in scope.
Publisher
,
Subscriber
NamedCollection.Option
Modifier and Type | Method and Description |
---|---|
default Publisher<V> |
createPublisher()
Create a
Publisher that can publish values into this NamedTopic . |
Publisher<V> |
createPublisher(Publisher.Option<? super V>... options)
Create a
Publisher that can publish values into this NamedTopic . |
default Subscriber<V> |
createSubscriber()
Create a direct
Subscriber to the topic that receives all values from this NamedTopic . |
<U> Subscriber<U> |
createSubscriber(Subscriber.Option<? super V,U>... options)
Create a
Subscriber that can receive values from this NamedTopic . |
void |
destroySubscriberGroup(String sGroupName)
Destroy the
named subscriber group for the associated topic. |
Set<String> |
getSubscriberGroups()
Return the set of
named subscriber group(s) and statically configured subscriber-group(s). |
default boolean |
isDestroyed()
Specifies whether or not this NamedTopic has been destroyed.
|
default boolean |
isReleased()
Specifies whether or not this NamedTopic has been released.
|
destroy, getName, getService
close, isActive, release
Publisher<V> createPublisher(Publisher.Option<? super V>... options)
Publisher
that can publish values into this NamedTopic
.options
- the Publisher.Option
s controlling the Publisher
Publisher
that can publish values into this NamedTopic
default Publisher<V> createPublisher()
Publisher
that can publish values into this NamedTopic
.Publisher
that can publish values into this NamedTopic
<U> Subscriber<U> createSubscriber(Subscriber.Option<? super V,U>... options)
Subscriber
that can receive values from this NamedTopic
.options
- the Subscriber.Option
s controlling the Subscriber
Subscriber
that can receive values from this NamedTopic
default Subscriber<V> createSubscriber()
Subscriber
to the topic that receives all values from this NamedTopic
.Subscriber
that can receive values from this NamedTopic
void destroySubscriberGroup(String sGroupName)
Set<String> getSubscriberGroups()
named
subscriber group(s) and statically configured subscriber-group(s).default boolean isDestroyed()
default boolean isReleased()