M
- the type of the subscribed messagesC
- the type of the context of messages or EmptyContext
if
messages do not have a contextW
- the type of the message that wraps a message and its context
(e.g. Event
); if subscribed message type does not have a context,
this parameter is likely to be the same as M
B
- the type of this requests for return type covariancepublic abstract class SubscribingRequest<M extends com.google.protobuf.Message,C extends io.spine.base.MessageContext,W extends com.google.protobuf.Message,B extends SubscribingRequest<M,C,W,B>> extends FilteringRequest<M,io.spine.client.Topic,TopicBuilder,B>
Modifier and Type | Method and Description |
---|---|
B |
observe(java.util.function.Consumer<M> consumer)
Subscribes the passed consumer to receive messages of the subscribed type.
|
B |
onConsumingError(ConsumerErrorHandler<M> handler)
Assigns a handler for an error that may occur in the code of one of the consumers.
|
B |
onStreamingError(ErrorHandler handler)
Assigns a handler for the error reported to
StreamObserver.onError(Throwable) of
the StreamObserver responsible for delivering messages
to the consumers. |
io.spine.client.Subscription |
post()
Creates and posts the subscription request to the server.
|
byId, byId, byId, byId, byId, where, where, withMask, withMask
client, command, onServerError, select, subscribeTo, subscribeToEvent, user
@CanIgnoreReturnValue public B observe(java.util.function.Consumer<M> consumer)
@CanIgnoreReturnValue @OverridingMethodsMustInvokeSuper public B onStreamingError(ErrorHandler handler)
StreamObserver.onError(Throwable)
of
the StreamObserver
responsible for delivering messages
to the consumers.
Once this handler is called, no more messages will be delivered to consumers.
onStreamingError
in class ClientRequest
SubscribingRequest.onConsumingError(ConsumerErrorHandler)
@CanIgnoreReturnValue public B onConsumingError(ConsumerErrorHandler<M> handler)
After this handler called, remaining consumers will get the message as usually.
public io.spine.client.Subscription post()