JasperFx 0.9.0


Next

Message Persistence

Previous

Jasper.Persistence.Marten

Jasper.Persistence.SqlServer Edit on GitHub


The Jasper.Persistence.SqlServer Nuget library provides Jasper users with a quick way to integrate Sql Server-backed persistence into their Jasper applications. To get started, just add the Jasper.Persistence.SqlServer Nuget to your project, and enable the persistence like this:


public class AppUsingSqlServer : JasperRegistry
{
    public AppUsingSqlServer()
    {
        // If you know the connection string
        Settings.PersistMessagesWithSqlServer("your connection string", schema:"my_app_schema");

        // Or using application configuration
        Settings.PersistMessagesWithSqlServer((context, settings) =>
        {
            if (context.HostingEnvironment.IsDevelopment())
            {
                // if so desired, the context argument gives you
                // access to both the IConfiguration and IHostingEnvironment
                // of the running application, so you could do
                // environment specific configuration here
            }

            settings.ConnectionString = context.Configuration["sqlserver"];

            // If your application uses a schema besides "dbo"
            settings.SchemaName = "my_app_schema";

            // If you're using a database principal that is NOT "dbo":
            settings.DatabasePrincipal = "not_dbo";
        });
    }
}

Enabling this configuration adds a couple things to your system: