Giter VIP home page Giter VIP logo

nservicebus.persistence.sql's Introduction

NServiceBus.SqlPersistence

Add support for NServiceBus to persist to a Sql Database.

Documentation

https://docs.particular.net/persistence/sql/

Running the tests

There are tests targetting multiple database engines. These can be installed on your machine or run in a docker container. The tests require a connectionstring set up in environment variables (remember that Visual Studio and Rider load these at start up, so restarting the IDE might be necessary).

SQL Server

For convenience, scripts have been provided in /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

MySql

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

Postgres

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;

Oracle

Docker:

docker run -d --name oracledb -p 1521:1521 -p 5500:5500 -e ORACLE_PWD=super-secret-password -e ORACLE_CHARACTERSET=AL32UTF8 oracle/database:18.4.0-xe

Above Oracle Database Express image can be created via the following procedure which is based on the official guidance for running Oracle Database 18c Express Edition in a Docker container.

  1. Clone https://github.com/oracle/docker-images/
  2. Download Oracle Database Express Edition (XE) Release 18.4.0.0.0 (18c)
  3. Move it to $/OracleDatabase/SingleInstance/dockerfiles/18.4.0
  4. Invoke $/OracleDatabase/SingleInstance/dockerfiles/buildDockerImage.sh (git bash or WSL) as ./buildDockerImage.sh -v 18.4.0 - x (build express image)

Environment variable:

NOTE: Requires building your own docker image

docker run -d --name oracledb -p 1521:1521 -p 5500:5500 -e ORACLE_PWD=super-secret-password -e ORACLE_CHARACTERSET=AL32UTF8 oracle/database:18.4.0-xe

Add an environment variable called OracleConnectionString with the connection string:

User Id=system;Password=super-secret-password;Data Source=localhost:1521/XEPDB1;

Smoke testing SQL Always Encrypted

In the Azure Portal, set up a dedicated resource group for testing purposes, that's cleaned up when the tests are completed.

  1. Create a SQL database
  2. Once deployed, access the SQL Server and go to "Firewalls and virtual networks" and add a rule that allows access from your local IP address
  3. Choose / download a sample that you want to smoke test, for example the SQL persistence simple saga sample
    • Remove all endpoints except for SQL Server
    • Adjust the connection string to point to the database you created
    • Remove the call to MarkAsComplete(). That will keep the saga alive so that you can inspect the data in the table
  4. Run the sample first with installers enabled
  5. Check the database. You should see a table for the saga data, with one row in it.
  6. Now we will encrypt some of the columns of the table
    • Right click on the table, and click 'Encrypt columns'
    • Choose the columns you want to encrypt, the ´Data´-column should be sufficient
    • Encryption type: Deterministic
    • Encryption key: a new one
    • Select Windows certificate store as a key store provider, under Current user
    • Choose 'Proceed to finish now'
    • Query the data to verify that the Data column's content is now encrypted
  7. Adjust to connection string in the sample
    • include Column Encryption Setting=Enabled;
    • Using a connecting builder, set ColumnEncryptionSetting = SqlConnectionColumnEncryptionSetting.Enabled
  8. Rerun the sample, everything should work as expected

nservicebus.persistence.sql's People

Contributors

simoncropp avatar szymonpobiega avatar dependabot[bot] avatar bording avatar danielmarbach avatar dependabot-preview[bot] avatar davidboike avatar lailabougria avatar adamralph avatar andreasohlund avatar weralabaj avatar tmasternak avatar timbussmann avatar ramonsmits avatar heskandari avatar soujay avatar scooletz avatar mauroservienti avatar williambza avatar particularbot avatar janovesk avatar seanfeldman avatar marcinhoppe avatar mikeminutillo avatar kentdr avatar seanfarmar avatar cquirosj avatar janv8000 avatar kbaley avatar larsw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.