Browse Source

Fixed some issues/updates.

FAMBL 1 year ago
parent
commit
61f4912cf1
2 changed files with 37 additions and 21 deletions
  1. 15 9
      services/synchronization.service.ts
  2. 22 12
      test/test3a.ts

+ 15 - 9
services/synchronization.service.ts

@@ -12,7 +12,7 @@ export class MessageSyncrhonizationService implements MessageSynchronisationServ
     private targetSrc: LoggingService = new LoggingService()
 
     public  init(settings: MessageSynchronisationServiceSetting): void {
-        this.settings = settings;
+        this.settings = settings; 
     }
 
     // Incoming obstriger serves as a trigger point to perform another synchronization
@@ -76,17 +76,23 @@ export class MessageSyncrhonizationService implements MessageSynchronisationServ
             }
             let set1
             let set2
-            this.sourceSrc.filter({ msgTag: this.settings.incomingSource.tags[0] }).then((data: MessageLog[]) => {
-                set1 = data
-            }).then(() => {
-                this.targetSrc.filter({ msgTag: this.settings.target.tags[0] }).then((data: MessageLog[]) => {
-                    set2 = data
-                    allSets.arr1 = set1
-                    allSets.arr2 = set2
-                    resolve(allSets)
+
+            
+        this.sourceSrc.init(this.settings.incomingSource).then(()=>{
+            this.targetSrc.init(this.settings.target).then(()=>{
+                this.sourceSrc.filter({ msgTag: this.settings.incomingSource.tags[0] }).then((data: MessageLog[]) => {
+                    set1 = data
+                }).then(() => {
+                    this.targetSrc.filter({ msgTag: this.settings.target.tags[0] }).then((data: MessageLog[]) => {
+                        set2 = data
+                        allSets.arr1 = set1
+                        allSets.arr2 = set2
+                        resolve(allSets)
+                    })
                 })
             })
         })
+        })
         return promiseQuery
     }
     // compare results and return differences`

+ 22 - 12
test/test3a.ts

@@ -1,6 +1,6 @@
 import { stat } from "fs";
 import { resolve } from "path";
-import { Observable, map, Subject, takeUntil, take, of, timer } from "rxjs";
+import { Observable, map, Subject, takeUntil, take, of, timer, from } from "rxjs";
 import { BaseMessage } from "../dependencies/fisappmessagejsutilty/dependencies/dependencies";
 import { LogSetting, MessageLog } from "../dependencies/fisloggingservice/type/datatype";
 import { AcknowledgementService } from "../services/acknowledgement.service";
@@ -117,19 +117,29 @@ const triggerSync = timer(5000).pipe(map(
 /* -------- SYNCHRONIZATION --------- */
 function initializeData() {
     source_incoming.init(source_dataSet)
-    target_incoming.init(target_dataSet)
-    setTimeout(() => {
-    }, 4500)
+    target_incoming.init(target_dataSet) 
 }
 
+// Done by 4 seconds
 initializeData()
-
 source_synchronize.init(settings)
-let sync = source_synchronize.subscribe(triggerSync)
-sync.subscribe({
-    next: (msgToBeSynched) => {
-        // console.log(`synching ... ${msgToBeSynched.header.messageID}`)
-        target_payload_subject.next(msgToBeSynched)
-    }
-})
 
+// by 5th second 
+setTimeout(() => { 
+
+    let triggerSync = from(['Newsynch'])
+ 
+    let sync = source_synchronize.subscribe(triggerSync)
+    sync.subscribe({
+        next: (msgToBeSynched) => {
+            // console.log(`synching ... ${msgToBeSynched.header.messageID}`)
+            target_payload_subject.next(msgToBeSynched)
+        }
+    })
+
+}, 30000)//30s
+
+// To DO
+// more test files
+// synch an additional source message at runtime(after 30sec)
+// more comments to be more readable