| 
					
				 | 
			
			
				@@ -4,12 +4,12 @@ Which is local file mongo as the control/source, and then comparing the data fro 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 server data, and then synchronizing them */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { Observable, map, Subject, takeUntil, take, of, timer, from } from "rxjs"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import { BaseMessage, ResponseMessage } from "../dependencies/msgutil/dependencies/dependencies"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import { LogSetting, MessageLog } from "../dependencies/log/type/datatype"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { ErrorTrigger, MessageSynchronisationServiceSetting } from "../type/datatype"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { StreamingService } from "./test-streamOBS"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { MessageAuditorService } from "../services/message-auditor.service"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import { LoggingService } from "../dependencies/log/services/logging-service"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { LoggingService } from "../dependencies/fisloggingservice/interface/export"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { BaseMessage, ResponseMessage } from "../dependencies/fisappmessagejsutilty/interface/export"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { LogSetting } from "../dependencies/fisloggingservice/type/datatype"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /* Pre - Defined Data && Settings */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // This service will stream the messages from the local testRequest.json messages 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -24,6 +24,9 @@ const publisher_sync = new MessageAuditorService() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const publisher_Log = new LoggingService() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const publisher_take_four_messages: Observable<BaseMessage> = stream.stream().pipe(take(4)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const publisher: Subject<BaseMessage> = new Subject() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+publisher.subscribe((e) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    console.log(`Primary Received ${e.header.messageID}`) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 publisher_take_four_messages.subscribe({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     next: (data) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         publisher.next(data) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -36,6 +39,9 @@ on. But generall the declarative structure is the same as the above. */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const subscriber_log = new LoggingService() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const subscriber_take_two_messagse: Observable<BaseMessage> = stream.stream().pipe(take(2)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const subscriber: Subject<BaseMessage> = new Subject() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+subscriber.subscribe((e) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    console.log(`Secondary Received ${e.header.messageID}`) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 subscriber_take_two_messagse.subscribe({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     next: (data) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         subscriber.next(<ResponseMessage>data) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -59,7 +65,7 @@ let publisher_storage: LogSetting = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     customSetting: { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         server: "192.168.100.59:27017", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        database: "test" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        database: "primary" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -80,7 +86,7 @@ let subscriber_storage: LogSetting = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         user: "testDB", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         password: "h1nt1OyXw6QeUnzS", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         server: "cluster0.29sklte.mongodb.net", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        database: "log", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        database: "secondary", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -103,15 +109,15 @@ let settings: MessageSynchronisationServiceSetting = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // messages into the designated database as specified earlier. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 function initializeData() { // To store the data into the designated databases. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     publisher_Log.init(publisher_storage).then(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        publisher_Log.subscribe(publisher) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        publisher_Log.subscribe(publisher) // Logging only occurs here 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     subscriber_log.init(subscriber_storage).then(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        subscriber_log.subscribe(subscriber) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        subscriber_log.subscribe(subscriber) // Logging only occurs here 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // Done by appoximately 5-8 Seconds 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-initializeData() // Call the function to store the data into the designated databases. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// initializeData() // Call the function to store the data into the designated databases. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 publisher_sync.init(settings) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /* This is where the synchronization logic is called. The errorSubject will act as a trigger 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -120,13 +126,15 @@ let errorSubject: Subject<ErrorTrigger> = new Subject() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // Subscribe to errorSubject notification  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 let sync = publisher_sync.subscribe(errorSubject) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 sync.subscribe({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    next: (msgToBeSynched) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        console.log(`synching ... ${msgToBeSynched.header.messageID}`) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    next: (msgToBeSynchronized) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        console.log(`passing missing message: ${msgToBeSynchronized.header.messageID} into target/secondary subject.`) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // the missing data returned will be pushed (next(message)) into the target payload. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        subscriber.next(msgToBeSynched) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        subscriber.next(msgToBeSynchronized) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // Set time oout for 5 seconds to allow the initial logging stage to complete it's logging 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // implementation first before proceedint to trigger the sync 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 setTimeout(() => { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -137,7 +145,7 @@ setTimeout(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         message: "NO. I dont want to work" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     errorSubject.next(sampleError) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-}, 5000) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+}, 10000) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /* THis is testing for generating error message to be fed into the error subject 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 to act as additional trigger to exectute the synchronization when there's no internet 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -172,4 +180,14 @@ const duration = 60000; // 1 minute 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 setTimeout(function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     clearInterval(interval); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     console.log('Internet connectivity monitoring stopped'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-}, duration); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+}, duration); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+function countdown() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let seconds = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const countUpInterval = setInterval(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      console.log(`Elapsed seconds: ${seconds}`); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      seconds++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 1000); // Update every second (1000 milliseconds) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+countdown() 
			 |