ASP.NET Core outbox with Cosmos DB

This question is similar to the one asked here.

The outbox pattern only works inside an NServiceBus Handler. However, for NoSQL DBs like Cosmos (and perhaps RavenDB), it would be great to get it working with ASP.NET Core Web API.

Propose scenario:

  • We save the data synchronously in Cosmos DB when calling a Web API along with events that need to be published to an outbox document in a single transaction batch.
  • A separate process/ worker reads the data from the outbox document and publishes the event.

Advantages of this approach
Saving the data in a separate process through a handler has its own complexity as we need to use additional services such as SignalR to notify the client when the data is saved. Hence, it would simplify most of the use cases since the save to DB is synchronous.

Hi @ankitvijay

We have released outbox support for ASP.NET Core scenarios with the transactional session package.

See for example this sample showing how to use the package together with CosmosDB as well as a more general sample showing how to integrate it with ASP.NET Core and SQL persistence.

Regards,
Daniel

1 Like