EventSubscriptionRequest

public final class EventSubscriptionRequest<E extends EventMessage> extends SubscribingRequest<M, C, W, B>

Allows to subscribe to events using filtering conditions.

Similarly to subscriptions to entity states, event subscriptions may use filtering by values of the proto types of subscribed messages:


clientRequest.subscribeToEvent(MyEventMessage.class)
             .where(eq(MyEventMessage.Field.myProtoField(), fieldValue))
             .observe((event, context) -> {...})
             .post();

In addition to regular filtering conditions, event subscription requests may also reference fields of spine.core.EventContext. For example, in order to filter events originate from commands of the given user, please use the following code:


clientRequest.subscribeToEvent(MyEventMessage.class)
             .where(eq(EventContext.Field.pastMessage().actorContext().actor(), userId))
             .observe((event, context) -> {...})
             .post();

Parameters

<E>

the type of the event messages

Functions

Link copied to clipboard
Link copied to clipboard
Configures the request to return results matching all the passed filters.

Inherited functions

Link copied to clipboard
public B byId(Array<Message> ids)
public B byId(Array<Integer> ids)
public B byId(Iterable<? extends Object> ids)
public B byId(Array<Long> ids)
public B byId(Array<String> ids)
Requests only passed IDs to be included into the result of the request.
Link copied to clipboard
protected Optional<StreamObserver<SubscriptionUpdate>> chain()
Returns an observer of raw SubscriptionUpdates, which will be called in addition to notifying the consumers.
Link copied to clipboard
protected final Client client()
Obtains the client instance that will perform the request.
Link copied to clipboard
public CommandRequest command(CommandMessage c)
Creates a builder for customizing command request.
Link copied to clipboard
public B observe(Consumer<M> consumer)
Subscribes the passed consumer to receive messages of the subscribed type.
Link copied to clipboard
Assigns a handler for an error that may occur in the code of one of the consumers.
Link copied to clipboard
Assigns a handler for an error occurred on the server-side (such as validation error) in response to posting a request.
Link copied to clipboard
Assigns a handler for errors occurred when delivering messages from the server.
public B onStreamingError(ErrorHandler handler)
Assigns a handler for the error reported to onError of the StreamObserver responsible for delivering messages to the consumers.
Link copied to clipboard
public Subscription post()
Creates and posts the subscription request to the server.
Link copied to clipboard
public QueryRequest<S> select<S extends EntityState>(Class<S> type)
Creates a builder for constructing a query for messages of the specified type.
Link copied to clipboard
public SubscriptionRequest<S> subscribeTo<S extends EntityState>(Class<S> type)
Creates a builder for customizing subscription for the passed entity state type.
Link copied to clipboard
public EventSubscriptionRequest<E> subscribeToEvent<E extends EventMessage>(Class<E> type)
Creates a builder for customizing subscription for the passed event type.
Link copied to clipboard
protected final UserId user()
Obtains the ID of the user of the request.
Link copied to clipboard
public B where(Array<CompositeFilter> filter)
public B where(Array<Filter> filter)
Configures the request to return results matching all the passed filters.
Link copied to clipboard
public B withMask(Iterable<String> fieldNames)
public B withMask(Array<String> fieldNames)
Instructs to populate only fields with the passed names in the results of the request.