Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
"AzureServiceBus": {
    "ConnectionString": "#{ServiceBusConnectionString}#",
    "TopicName": "#{DefaultTopicName}#",
    "Subscription": "#{DefaultSubscriptionName}#",
    "SubscriptionToTopics": {
      "subscription1": "#{Topics1}#",
      "subscription2”: "#{Topics2}#"
    },
    "FailedRetryCount": 10,
    "FailedRetryInterval": 60
  },
  "ConnectionStrings": {
    "PostgreSql": "#{EDACAPConnectionStringPostgreSql}#"
  }
 After

 

Please note, all connectionString and Topics are based on your instance of Service Bus implementation which can be located under your instance of Service Bus/Shared Access Policies.

...

After adding those settings into appsettings, we need to use those values in ConfigureServices in startup.cs during services configuration as following:

Code Block
#region CAP implementation
  string connectString = Configuration.GetValue<string>("ConnectionStrings:PostgreSql");
  string? schema = Assembly.GetEntryAssembly()?.GetName().Name?.ToLower();
            services.AddCap(x =>
              {
                  x.UseAzureServiceBus(opt =>
                  {
                      opt.ConnectionString = Configuration.GetValue<string>("AzureServiceBus:ConnectionString");
                      opt.TopicPath = Configuration.GetValue<string>("AzureServiceBus:TopicName");
                      opt.SubscriptionToTopics = Configuration.GetSection("AzureServiceBus:SubscriptionToTopics")
                      .GetChildren().ToDictionary(x => x.Key, x => x.Value);
                  });
                  x.DefaultGroupName = Configuration.GetValue<string>("AzureServiceBus:Subscription");
                  x.FailedRetryCount = Configuration.GetValue<int>("AzureServiceBus:FailedRetryCount");
                  x.FailedRetryInterval = Configuration.GetValue<int>("AzureServiceBus:FailedRetryInterval");
                  x.UsePostgreSql(x => { x.ConnectionString = connectString; x.Schema = schema; });
              });

#endregion

Note: if you have an error in the line 3, please add using System.Reflection;

Publishing and Subscribing Messages

...

Selected CAP library supports OutBox and InBox Pattern on top of Event Driven out of box. The idea behind this pattern ensures that the message will be not lost if we lose the network, for example.

...

When Application starts, CAP library will automatically generate two tables named Published and Received under application schemas as default based on storage type we configured in startsup.

...

·        Project Repository: EDASampleApi

·        Cross platform EDA white paper: Power App integrate with .NET through EDA

·        CAP library Page: https://cap.dotnetcore.xyz

...