You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

31 lines
825 B

  1. using DotNetCore.CAP.Internal;
  2. using Sample.AzureServiceBus.InMemory;
  3. var builder = WebApplication.CreateBuilder(args);
  4. builder.Services.AddLogging(l => l.AddConsole());
  5. builder.Services.AddCap(c =>
  6. {
  7. c.UseInMemoryStorage();
  8. c.UseAzureServiceBus(asb =>
  9. {
  10. asb.ConnectionString = builder.Configuration.GetConnectionString("AzureServiceBus");
  11. asb.CustomHeaders = message => new List<KeyValuePair<string, string>>()
  12. {
  13. new(DotNetCore.CAP.Messages.Headers.MessageId,
  14. SnowflakeId.Default().NextId().ToString()),
  15. new(DotNetCore.CAP.Messages.Headers.MessageName, message.Label)
  16. };
  17. });
  18. c.UseDashboard();
  19. });
  20. builder.Services.AddSingleton<SampleSubscriber>();
  21. var app = builder.Build();
  22. app.MapGet("/", () => "Hello World!");
  23. app.Run();