Package com.pushtechnology.diffusion.client.features
This package contains the standard client features.
A feature
represents a unit of functionality that is available to use within a client
session
.
Standard client features include:
Topics
This feature allows a client to subscribe to topics in order to receive
streaming updates. It also allows a client to fetch the state of topics
without having to subscribe to them.
Messaging
This feature allows a client to send messages on a topic (to be delivered to
the controller of that topic) or receive messages on topics (send by topic
controllers).
Pings
This feature allows a client to ping the server to ensure connectivity and
to obtain round trip timings.
Security
This feature allows a client to change it's principal.
A feature may be obtained from a session using the
feature
method specifying the feature class. For example:
Topics topics = session.feature(Topics.class);
CompletableFuture
Since version 6.0, the API has been extended to support Java 8's CompletableFuture. All methods that have a callback that produces a single outcome now have an alternative that returns the outcome using a CompletableFuture rather than a callback.
CompletableFuture<?>
Some methods have a return type of CompletableFuture<?>
. The result
type is a wildcard rather than Void
to provide forward compatibility
with future iterations of this API that may provide a non-null result with a
more specific result type. If such a method is called and the task completes
successfully, the CompletableFuture result will be null.
Blocking methods are unsupported when chaining CompletableFutures
Calling a blocking CompletableFuture method, such as
get
or
join
, from a Diffusion
thread is disallowed since doing so can cause the client to deadlock because
the same thread is used to deliver responses from the server to the session.
This situation typically happens when chaining CompletableFutures. To protect
against deadlock, Diffusion detects the use of a blocking method from a
Diffusion thread, and completes the CompletableFuture exceptionally with a
UnsupportedOperationException
. For example:
messaging.sendMessage("x", "m1", String.class, String.class) .thenAccept(r1 -> { // This will run in the Diffusion input thread, when the // result of the first call is received. CompletableFuture<String> cf = messaging.sendMessage("y", r1, String.class, String.class); // This will immediately throw an ExecutionException with an // UnsupportedOperationException cause. String r2 = cf.get(); // Not reached. LOG.info("Result {}", r2); });
To avoid the problem, when calling a second Diffusion method from a handler
attached to a Diffusion-supplied CompletableFuture, only use non-blocking
methods such as
thenAccept
on the result returned by the second method. For example:
messaging.sendMessage("x", "m1", String.class, String.class) .thenAccept(r1 -> { // This will run in the Diffusion input thread, when the // result of the first call is received. CompletableFuture<String> cf = messaging.sendMessage("y", r1, String.class, String.class); cf.thenAccept(r2 -> { LOG.info("Result {}", r2); }); });
The blocking call protection is effective against the use of get
and
join
, but does not work if a CompletableFuture is exposed indirectly
as a stage of a plain, unprotected CompletableFuture via
allOf()
,
anyOf
,
thenCombine
,
acceptEither
, etc.
- Since:
- 5.0
- Author:
- DiffusionData Limited
-
ClassDescriptionIndicates a cluster operation failed because partition ownership changed during processing.Indicates a cluster operation failed to be routed to a server within the cluster due to a communication failure.Thrown to report one or more
ErrorReport
s}.Thrown to indicate a handler could not be registered because it conflicts with an existing handler.Exception used to report that an operation has failed because the receiver could not process the supplied data.Exception used to report a topic is incompatible with an operation.An operation could not be performed because the topic is managed by a component (such as fan-out) that prohibits updates from the caller.Exception used to report a filter expression is invalid.Exception used to report an operation was performed with an invalidupdate stream
.This feature provides a client session with request-response messaging capabilities that can be used to implement application services.Callback interface for requests dispatched through a filter.Default implementation ofMessaging.FilteredRequestCallback
.Interface which specifies a request handler to receive request notifications.Context of the request received.Responder interface to dispatch responses to requests.Interface which specifies a request stream to receive request notifications.Responder interface to dispatch responses to requests.Exception used to report there is no session for a given session ID.Exception used to report there is no topic bound to a topic path.This feature provides a client session with the ability to test its connection to the server.Server response to a ping.An extension toUpdateStream
that includes recovery functionality.Exception used to report that a recipient session has rejected a request.Exception used to report problems evaluating a script.This feature provides a client session with the ability to re-authenticate the session, as well as to query permissions assigned to it.This feature allows a session to update and query time series topics.An event in a time series.Time series event metadata.Exception used to report a query that is invalid for the time series.Exception used to report a time series topic does not have an original event with the sequence number provided by anedit
operation.A configured query.Query result providing astream of events
.Describes the structural properties of a stream.Builder for queries that select a range of events from a time series.Result indicating whether the operation caused a topic to be created or if it already existed.This feature allows a client session to subscribe to topics to receive streamed topic updates, fetch the state of topics and/or update topics with new values.A parameterised query that can be used to search the topic tree.Encapsulates the results from a fetch operation issued to the server.Encapsulates the result of afetch
invocation for a single selected topic.Base subscriber stream interface.DefaultTopics.SubscriberStream
implementation.The reason that an unsubscription occurred.Stream interface that can be registered to receive subscription and value events whenever an update is received from the server.DefaultTopics.ValueStream
implementation.This feature provides a client session with the ability to update topics.Exception thrown to report that applying a JSON Patch failed.Exception thrown to report that a JSON Patch was invalid.Exception used to report a message was not delivered to an application handler.Exception used to report that a constraint was not satisfied.A constraint to be applied to an update operation or the creation of an update stream.Factory for the constraint types.An operator used in a constraint comparison.A constraint requiring the current value of aJSON
topic to match the partially described value.Exception used to report a topic update failed.UpdateStream<T>An update stream provides a method for updating a specific topic.Builder forupdate stream
to use for updating a specific topic.Exception used to report the update stream buffer have exceeded its limit.Exception used to report the number of retry attempts have exceeded the limit.