NServiceBus.SqlPersistence provides support for NServiceBus to persist in a Sql Database.
It is part of the Particular Service Platform, which includes NServiceBus and tools to build, monitor, and debug distributed systems.
See the Sql Persistence documentation for more details on how to use it.
There are tests targeting multiple database engines. These can be installed on your machine or run in a Docker container. The tests require a connection string set up in environment variables (remember that Visual Studio and Rider load these at start up, so restarting the IDE might be necessary).
For convenience, scripts have been provided in a /dev
folder.
Docker:
docker run --name SqlServer -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=NServiceBusPwd!" -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest
Environment variable:
Add an environment variable called SQLServerConnectionString
with the connection string:
Server=localhost;User Id=sa;Password=NServiceBusPwd!;Database=nservicebus
Docker:
docker run --rm --name test-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=my-super-secret-password -e MYSQL_DATABASE=NServiceBus -e MYSQL_USER=nsbuser -e MYSQL_PASSWORD=nsbuser-super-secret-pwd -d mysql:latest
Environment variable:
Add an environment variable called MySQLConnectionString
with the connection string:
Server=localhost;Port=3306;Database=NServiceBus;Uid=nsbuser;Pwd=nsbuser-super-secret-pwd;AllowUserVariables=True;AutoEnlist=false
Docker:
docker run -d --name PostgresDb -v my_dbdata:/var/lib/postgresql/data -p 54320:5432 -e POSTGRES_PASSWORD=super-secret-password postgres:11
Environment variable:
Add an environment variable called PostgreSqlConnectionString
with the connection string:
User ID=postgres;Password=super-secret-password;Host=localhost;Port=54320;Database=nservicebus;Pooling=true;
Docker (using the lightweight community image that we also use for CI/CD):
docker run -d --name oracledb -p 1521:1521 -p 5500:5500 -e ORACLE_PASSWORD=super-secret-password gvenzl/oracle-xe:21.3.0-slim
Docker (official image):
docker run -d --name oracledb -p 1521:1521 -p 5500:5500 -e ORACLE_PWD=super-secret-password -e ORACLE_CHARACTERSET=AL32UTF8 container-registry.oracle.com/database/express:21.3.0-xe
Add an environment variable called OracleConnectionString
with the connection string:
User Id=system;Password=super-secret-password;Data Source=localhost:1521/XEPDB1;
In the Azure Portal, set up a dedicated resource group for testing purposes, that's cleaned up when the tests are completed.
MarkAsComplete()
. That will keep the saga alive so that you can inspect the data in the tableColumn Encryption Setting=Enabled;
ColumnEncryptionSetting = SqlConnectionColumnEncryptionSetting.Enabled