Skip to content

Instantly share code, notes, and snippets.

@ankitvijay
Last active October 9, 2021 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ankitvijay/2e486b97c72f3de166ca1b304299c6a0 to your computer and use it in GitHub Desktop.
Save ankitvijay/2e486b97c72f3de166ca1b304299c6a0 to your computer and use it in GitHub Desktop.
NServiceBus Cosmos Sample - Worker Host
await Host.CreateDefaultBuilder(args)
.UseNServiceBus((_ =>
{
var endpointConfiguration = new EndpointConfiguration("Samples.Worker");
var transport = endpointConfiguration.UseTransport<LearningTransport>();
transport.Transactions(TransportTransactionMode.SendsAtomicWithReceive);
endpointConfiguration.UsePersistence<CosmosPersistence>()
// Using Cosmos emulator
.CosmosClient(new CosmosClient(
"AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="))
.DatabaseName("Twitbook")
.DefaultContainer("Posts", "/PostId");
endpointConfiguration.EnableOutbox();
endpointConfiguration.Pipeline.Register(new PostIdAsPartitionKeyBehavior.Registration());
endpointConfiguration.EnableInstallers();
return endpointConfiguration;
}))
.Build()
.RunAsync();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment