Dkeshri.DataSync.DBChangeEmitter
1.0.3
See the version list below for details.
dotnet add package Dkeshri.DataSync.DBChangeEmitter --version 1.0.3
NuGet\Install-Package Dkeshri.DataSync.DBChangeEmitter -Version 1.0.3
<PackageReference Include="Dkeshri.DataSync.DBChangeEmitter" Version="1.0.3" />
paket add Dkeshri.DataSync.DBChangeEmitter --version 1.0.3
#r "nuget: Dkeshri.DataSync.DBChangeEmitter, 1.0.3"
// Install Dkeshri.DataSync.DBChangeEmitter as a Cake Addin #addin nuget:?package=Dkeshri.DataSync.DBChangeEmitter&version=1.0.3 // Install Dkeshri.DataSync.DBChangeEmitter as a Cake Tool #tool nuget:?package=Dkeshri.DataSync.DBChangeEmitter&version=1.0.3
Data-Sync-Emmiter
This application help to track the change in MsSql
Database changes and send that changes to RabbitMq
Message broker. On Start of this application it create a Table called ChangeTrackers, Which contain list of tables that will be tracked. There is hosted service which check the Database change in every 10 secs and Send that changes to RabbiMq queue (default_queue: DataSyncQueue).
Installation Steps
Pre-requisite
Enable Change tracking on Database
If not enabled please run below command.
ALTER DATABASE YourDatabaseName
SET CHANGE_TRACKING = ON
(CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON);
How to use
This package uses the IServiceCollection
to setup. There is an Extension AddDataSyncDbChangeEmitter
Method is use to setup.
You need to provide Message Broker Details (like rabbitMq
) and MsSql
Connection details to work this package.
services.AddDataSyncDbChangeEmitter((config) =>
{
config.AddRabbitMqBroker((rabbitMqConfig) =>
{
rabbitMqConfig.HostName = "localhost";
rabbitMqConfig.Port = 5672;
rabbitMqConfig.QueueName = "DataSyncQueue";
rabbitMqConfig.UserName = "guest";
rabbitMqConfig.Password = "guest";
});
config.AddDataLayer((dbType,config) =>
{
dbType = DatabaseType.MSSQL;
config.ConnectionString = "Server=hostIP;Database=DatabaseName;User Id=userId;Password=UourDbPassword;Encrypt=False";
config.TransactionTimeOutInSec = 30;
});
});
Example:
Lets say we have .Net Core Console Application
, Use below code in Program.cs
file and run the application.
using Dkeshri.DataSync.DBChangeEmitter.Extensions;
using Microsoft.Extensions.Hosting;
var builder = Host.CreateDefaultBuilder(args);
builder.ConfigureServices((hostContext, services) =>
{
services.AddDataSyncDbChangeEmitter((config) =>
{
config.AddRabbitMqBroker((rabbitMqConfig) =>
{
rabbitMqConfig.HostName = "localhost";
rabbitMqConfig.Port = 5672;
rabbitMqConfig.QueueName = "DataSyncQueue";
rabbitMqConfig.UserName = "guest";
rabbitMqConfig.Password = "guest";
});
config.AddDataLayer((dbType,config) =>
{
dbType = DatabaseType.MSSQL;
config.ConnectionString = "Server=hostIP;Database=DatabaseName;User Id=userId;Password=UourDbPassword;Encrypt=False";
config.TransactionTimeOutInSec = 30;
});
});
});
builder.RunConsoleAsync().Wait();
Configuration.
After running this application, it will perform database migration, creating a table named ChangeTrackers
in your database.
You need to insert your table into the ChangeTrackers
table. This table contains two columns: TableName
and ChangeVersion
. You need to set initial value as 0
to ChangeVersion
column.
use below query to insert tableName.
INSERT Into ChangeTrackers (TableName,ChangeVersion)
VALUES('YourTableName',0);
Note: Make sure dependent tableName should be there in ChangeTrackers. **Example 😗*
let say you have two tables orders
and ordersSummary
tables, Orders
table has foreign refrance of ordersSummary
table then you have to insert both tableName (orders
and OrdersSummary
) in ChangeTrackers
Table.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
-
net8.0
- Dkeshri.DataSync.Common (>= 1.0.3)
- Dkeshri.MessageQueue.RabbitMq (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.