E
- the type of the event messagespublic final class EventSubscriptionRequest<E extends io.spine.base.EventMessage> extends SubscribingRequest<E,io.spine.core.EventContext,io.spine.core.Event,EventSubscriptionRequest<E>>
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();
Modifier and Type | Method and Description |
---|---|
EventSubscriptionRequest<E> |
observe(EventConsumer<E> consumer) |
EventSubscriptionRequest<E> |
where(CompositeEventFilter... filter)
Configures the request to return results matching all the passed filters.
|
EventSubscriptionRequest<E> |
where(EventFilter... filter)
Configures the request to return results matching all the passed filters.
|
observe, onConsumingError, onStreamingError, post
byId, byId, byId, byId, byId, where, where, withMask, withMask
client, command, onServerError, select, subscribeTo, subscribeToEvent, user
public EventSubscriptionRequest<E> where(EventFilter... filter)
Please note that the EventFilter
instances may target both event message and
event context fields. See EventFilter
for details.
public EventSubscriptionRequest<E> where(CompositeEventFilter... filter)
Please note that the CompositeEventFilter
instances may target both event message
and event context fields. See CompositeEventFilter
for details.
@CanIgnoreReturnValue public EventSubscriptionRequest<E> observe(EventConsumer<E> consumer)