Cratis Chronicle reducer subscriptions to external event stores
Cratis Chronicle’s .NET client can subscribe a reducer to another event store by forwarding its handled event types from the source outbox to a local inbox. Use event-store metadata when Chronicle should select the inbox and create the subscription for you.
For a subscription you configure yourself, use explicit event-store subscriptions.
Self-reducing read models use the same inbox routing. Chronicle derives their subscription event types from the static transitions selected by the owning registry, not from query methods or unrelated helpers.
Automatic Inbox Routing
Section titled “Automatic Inbox Routing”Declare the source with [EventStore("...")] on event types or their assembly. When the handled events identify a single external source and the reducer has no explicit event sequence, Chronicle selects that source’s inbox. Events belonging to the current store continue to use the local event log.
For example, events from fulfillment-service arrive in inbox-fulfillment-service, which the reducer observes:
using Cratis.Chronicle.Events;using Cratis.Chronicle.Reducers;
[EventType][EventStore("fulfillment-service")]public record ExternalReducerShipmentDispatched(Guid OrderId, string TrackingNumber);
public record ExternalReducerFulfillmentStatus(string Status, string TrackingNumber);
public class ExternalReducerFulfillmentStatusReducer : IReducerFor<ExternalReducerFulfillmentStatus>{ public ExternalReducerFulfillmentStatus Dispatched(ExternalReducerShipmentDispatched @event, ExternalReducerFulfillmentStatus? current, EventContext context) => new("Dispatched", @event.TrackingNumber);}Kotlin does not support this workflow yet.Java does not support this workflow yet.Elixir does not support this workflow yet.TypeScript does not support this workflow yet.Observer-Level EventStore for Missing Event Metadata
Section titled “Observer-Level EventStore for Missing Event Metadata”When event contracts cannot carry [EventStore] metadata, apply [EventStore] directly on the reducer.
Chronicle selects that source’s inbox and creates or reuses the outbox-to-inbox subscription. For a self-reducing read model, put [EventStore] on the model instead.
using Cratis.Chronicle.Events;using Cratis.Chronicle.Reducers;
[EventType]public record ExternalReducerUserInvited(Guid UserId);
public record ExternalReducerUserTotals(int Count);
[EventStore("identity-service")][Reducer]public class ExternalReducerUserTotalsReducer : IReducerFor<ExternalReducerUserTotals>{ public ExternalReducerUserTotals Invited(ExternalReducerUserInvited @event, ExternalReducerUserTotals? current, EventContext context) => new((current?.Count ?? 0) + 1);}Kotlin does not support this workflow yet.Java does not support this workflow yet.Elixir does not support this workflow yet.TypeScript does not support this workflow yet.Implicit Combined Event Type Filtering
Section titled “Implicit Combined Event Type Filtering”Chronicle creates one implicit subscription per source event store, combining the handled event types of participating reducers and reactors. External-store projection subscriptions also contribute their event types to this combined filter.
Adding a reducer that handles another event type widens the subscription’s event-type filter; it does not create a separate subscription for that reducer. The source forwards the combined set to the target inbox, and each reducer still receives only the event types and metadata matches it observes.
Explicit Event Sequence Is Not Allowed with Observer EventStore
Section titled “Explicit Event Sequence Is Not Allowed with Observer EventStore”When a reducer has [EventStore("...")], do not combine it with:
[EventSequence("...")][EventLog][Reducer(eventSequence: "...")]
The .NET client rejects this combination with EventStoreCannotBeCombinedWithExplicitEventSequence; analyzer rule CHR0014 reports it at compile time. Remove the explicit sequence to use automatic inbox routing, or remove the reducer’s [EventStore] to select a sequence yourself.
Forwarded metadata
Section titled “Forwarded metadata”Inbox forwarding preserves append tags, event source type, and stream-route metadata. Both separate reducers and self-reducing read models can use metadata filters to select forwarded events.
Events forwarded by earlier releases that dropped tags remain untagged; upgrading does not backfill them. Check the stored inbox metadata when an older event does not match a tag filter.