Akka.Persistence.SqlServer.Hosting

May 4, 2023 ยท View on GitHub

Akka.Hosting extension methods to add Akka.Persistence.SqlServer to an ActorSystem

Akka.Persistence.SqlServer Extension Methods

WithSqlServerPersistence() Method

public static AkkaConfigurationBuilder WithSqlServerPersistence(
    this AkkaConfigurationBuilder builder,
    string connectionString,
    PersistenceMode mode = PersistenceMode.Both, 
    Action<AkkaPersistenceJournalBuilder>? configurator = null,
    bool autoInitialize = true);
public static AkkaConfigurationBuilder WithSqlServerPersistence(
    this AkkaConfigurationBuilder builder,
    Action<SqlServerJournalOptions>? journalConfigurator = null,
    Action<SqlServerSnapshotOptions>? snapshotConfigurator = null,
    Action<AkkaPersistenceJournalBuilder>? configurator = null);
public static AkkaConfigurationBuilder WithSqlServerPersistence(
    this AkkaConfigurationBuilder builder,
    SqlServerJournalOptions? journalOptions = null,
    SqlServerSnapshotOptions? snapshotOptions = null,
    Action<AkkaPersistenceJournalBuilder>? configurator = null);

Parameters

  • connectionString string

    Connection string used for database access.

  • mode PersistenceMode

    Determines which settings should be added by this method call.

    • PersistenceMode.Journal: Only add the journal settings
    • PersistenceMode.SnapshotStore: Only add the snapshot store settings
    • PersistenceMode.Both: Add both journal and snapshot store settings
  • configurator Action<AkkaPersistenceJournalBuilder>

    An Action delegate used to configure an AkkaPersistenceJournalBuilder instance. Used to configure Event Adapters

  • journalConfigurator Action<SqlServerJournalOptions>

    An Action delegate to configure a SqlServerJournalOptions instance.

  • snapshotConfigurator Action<SqlServerSnapshotOptions>

    An Action delegate to configure a SqlServerSnapshotOptions instance.

  • journalOptions SqlServerJournalOptions

    An SqlServerJournalOptions instance to configure the SqlServer journal.

  • snapshotOptions SqlServerSnapshotOptions

    An SqlServerSnapshotOptions instance to configure the SqlServer snapshot store.

Example

using var host = new HostBuilder()
    .ConfigureServices((context, services) =>
    {
        services.AddAkka("ecsBootstrapDemo", (builder, provider) =>
        {
            builder
                .WithRemoting("localhost", 8110)
                .WithClustering()
                .WithSqlServerPersistence("your-sqlserver-connection-string");
        });
    }).Build();

await host.RunAsync();