This image integrate with MsSql Database and RabitMq Message broker Send Changes to RabbitMq
1.3K
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).
Note: Before running image need some steps to perform
If not enabled please run below command.
ALTER DATABASE YourDatabaseName
SET CHANGE_TRACKING = ON
(CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON);
docker run -d -v rabbitmqv:/var/log/rabbitmq --hostname rmq --name RabbitMqServer \
-p 5672:5672 -p 8080:15672 rabbitmq:3.13-management
Create docker-compose.yml file on your system and put below code in that file.
services:
data-sync-emitter:
container_name: data-sync-emitter
image: dkeshri/data-sync-emitter:latest
environment:
- ConnectionStrings__DefaultConnection=Server=host.docker.internal,1433;Database=DatabaseName;User Id=userid;Password=Password;Encrypt=False
- RabbitMq__HostName=host.docker.internal
- RabbitMq__Port=5672
- RabbitMq__UserName=guest
- RabbitMq__Password=guest
- RabbitMq__ClientProvidedName=Sender
- RabbitMq__MessageRoutingKey=EmitterToReceiver
- RabbitMq__Exchange__Name=DataSyncExchange
Run below command
docker-compose -f .\docker-compose.yml up -d
PowerShell
docker run -d `
-e RabbitMq__HostName=host.docker.internal `
-e RabbitMq__Port=5672 `
-e RabbitMq__UserName=guest `
-e RabbitMq__Password=guest `
-e RabbitMq__ClientProvidedName=Sender `
-e RabbitMq__Exchange__Name=DataSyncExchange `
-e RabbitMq__MessageRoutingKey=EmitterToReceiver `
-e ConnectionStrings__DefaultConnection="Server=host.docker.internal,1433;Database=YourDataBaseName;User Id=sa;Password=YourSqlPassword;Encrypt=False" `
--name data-sync-emitter `
dkeshri/data-sync-emitter:latest
You need to insert your table in ChangeTrackers Table. This table contains two column TableName and ChangeVersion.
For ChangeVersion you need to set 0 as initial version
INSERT Into ChangeTrackers (TableName,ChangeVersion)
VALUES('YourTableName',0);
Note: Make sure dependent tableName should also be there in ChangeTrackers.
let say you have two tables orders and ordersSummary table and orders table has foreign refrance of ordersSummary table then you have to insert both tableName (orders and OrdersSummary) in ChangeTrackers Table.
After adding tables to the
ChangeTrackerstable, you need to restart the Emitter application to enable change tracking for the newly added tables.
If you don't want to restart the Emitter application, run the following query to manually enable change tracking
ALTER TABLE TableName
ENABLE CHANGE_TRACKING;
Content type
Image
Digest
sha256:bd3875462…
Size
83.2 MB
Last updated
over 1 year ago
docker pull dkeshri/data-sync-emitter