FSharpWorks.Outbox.MSSQL
0.1.22
See the version list below for details.
dotnet add package FSharpWorks.Outbox.MSSQL --version 0.1.22
NuGet\Install-Package FSharpWorks.Outbox.MSSQL -Version 0.1.22
<PackageReference Include="FSharpWorks.Outbox.MSSQL" Version="0.1.22" />
<PackageVersion Include="FSharpWorks.Outbox.MSSQL" Version="0.1.22" />
<PackageReference Include="FSharpWorks.Outbox.MSSQL" />
paket add FSharpWorks.Outbox.MSSQL --version 0.1.22
#r "nuget: FSharpWorks.Outbox.MSSQL, 0.1.22"
#:package FSharpWorks.Outbox.MSSQL@0.1.22
#addin nuget:?package=FSharpWorks.Outbox.MSSQL&version=0.1.22
#tool nuget:?package=FSharpWorks.Outbox.MSSQL&version=0.1.22
FSharpWorks.Outbox.MSSQL
An MSSQL backend for FSharpWorks.Outbox: transactional outbox pattern implementation.
Using the MSSQL backend
Please refer to Readme in FSharpWorks.Outbox project for a complete example.
In order to create a backend, MSSQL.createBackend function is used:
Example (F#)
open FSharpWorks.Outbox
let dbOptions =
{ connectionString = ConnectionString "Server=127.0.0.1;Database=service;User Id=sa;Password=Password1"
schema = SchemaName "dbo"
name = OutboxName "my-outbox" }
// Use Postgres backend in this example
let mssqlBackend = MSSQL.createBackend dbOptions
Example (C#)
using FSharpWorks.Outbox
using FSharpWorks.Outbox.CSharp
var dbOptions = OutboxFactory.CreateOutboxParams(
ConnectionString.NewConnectionString("Server=127.0.0.1;Database=service;User Id=sa;Password=Password1"),
SchemaName.NewSchemaName("dbo"),
OutboxName.NewOutboxName("my-outbox"));
// Use MSSQL backend in this example
var mssqlBackend = MSSQL.CreateBackend(dbOptions);
The backend then can be used for creating FSharpWorks.Outbox.
Schema
DB Schema can be automatically set up by the backend or it can be set up externally (for example, using DB deployment/provisioning tools).
When an auto-initialisation is called for an outbox named MyOutbox,
the following schema will be generated in the DB:
CREATE SEQUENCE MyOutboxSequence
AS [bigint]
START WITH 1
INCREMENT BY 1
NO CYCLE
NO CACHE
GO
CREATE TABLE [MyOutbox] (
[SequenceId] BIGINT NOT NULL DEFAULT NEXT VALUE FOR MyOutboxSequence,
[RowVersion] ROWVERSION NOT NULL,
[MessageType] VARCHAR(255) NOT NULL,
[Payload] VARBINARY(MAX) NOT NULL,
[DateAddedUtc] DATETIME2(3) NOT NULL DEFAULT SYSUTCDATETIME(),
CONSTRAINT [PK_MyOutbox] PRIMARY KEY NONCLUSTERED([SequenceId])
WITH (FILLFACTOR = 100, DATA_COMPRESSION = PAGE)
)
GO
CREATE CLUSTERED INDEX [IX_MyOutbox]
ON [MyOutbox]([RowVersion])
WITH (FILLFACTOR = 100, DATA_COMPRESSION = PAGE)
GO
CREATE PROCEDURE MyOutbox_Enqueue (
@MessageType AS VARCHAR(255),
@Payload AS VARBINARY(MAX)
) AS
INSERT INTO [MyOutbox] ([MessageType], [Payload])
VALUES (@MessageType, @Payload)
GO
CREATE PROCEDURE MyOutbox_Dequeue (
@MAX_MESSAGES_NUM AS INT = 5
) AS
WITH OrderedOutboxMessages AS (
SELECT TOP (@MAX_MESSAGES_NUM) *
FROM
[MyOutbox] WITH(UPDLOCK, READPAST)
WHERE
[RowVersion] <= MIN_ACTIVE_ROWVERSION()
ORDER BY
[RowVersion]
)
DELETE
FROM OrderedOutboxMessages
OUTPUT DELETED.*
Tuning the schema
The backend only relies on two stored procedures:
<outbox-name>_Enqueuefor enqueuing messages into the outbox<outbox-name>_Dequeuefor dequeuing messages and dispatching them externally.
As long as they exist (and comply with their expected signatures, see the schema above), the rest of the schema (tables, indices, procedures' implementations) can be changed freely as it is never used by the backend directly.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net5.0
- FSharp.Control.AsyncSeq (>= 3.0.3)
- FSharp.Core (>= 5.0.0)
- FSharpWorks.Outbox (>= 0.1.22)
- Microsoft.Data.SqlClient (>= 3.0.0)
- SmartFormat.NET (>= 2.7.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.35 | 4,218 | 7/22/2021 |
| 0.1.34 | 423 | 7/22/2021 |
| 0.1.33 | 405 | 7/21/2021 |
| 0.1.32 | 427 | 7/19/2021 |
| 0.1.31 | 434 | 7/19/2021 |
| 0.1.28 | 484 | 7/15/2021 |
| 0.1.27 | 466 | 7/14/2021 |
| 0.1.25 | 433 | 7/14/2021 |
| 0.1.24 | 453 | 7/14/2021 |
| 0.1.23 | 479 | 7/13/2021 |
| 0.1.22 | 483 | 7/9/2021 |
| 0.1.21 | 472 | 7/8/2021 |
| 0.1.17 | 443 | 7/6/2021 |
| 0.1.14 | 455 | 7/2/2021 |
| 0.1.13 | 475 | 7/1/2021 |