A practical guide to building custom Marten projections that write to Elasticsearch asynchronously. The post walks through implementing the IProjection interface, creating a reusable ElasticsearchProjection base class, and a typed generic variant that lets developers register per-event apply lambdas. Key design decisions include using Marten's async daemon for ordering and delivery guarantees, avoiding two-phase commit by relying on eventual consistency, and leveraging Elasticsearch's bulk API for efficient batch indexing. A concrete Order domain example illustrates the full pattern, which can be adapted for other external stores like MongoDB or Neo4j.
2 Impressions