| 
					
				 | 
			
			
				@@ -1,5 +1,6 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { stat } from "fs"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { resolve } from "path"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import { Observable, map, Subject, takeUntil, take } from "rxjs"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { Observable, map, Subject, takeUntil, take, of, timer } from "rxjs"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { BaseMessage } from "../dependencies/fisappmessagejsutilty/dependencies/dependencies"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { LogSetting, MessageLog } from "../dependencies/fisloggingservice/type/datatype"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { AcknowledgementService } from "../services/acknowledgement.service"; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -14,7 +15,7 @@ const stream = new StreamingService() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // Declare source Services && Observables (Using File Storage) Simulating Full Logs 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const source_synchronize = new MessageSyncrhonizationService() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-const source_payload: Observable<BaseMessage> = stream.stream().pipe() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+const source_payload: Observable<BaseMessage> = stream.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const source_incoming = new IncomingMessageService() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const source_payload_subject: Subject<BaseMessage> = new Subject() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 source_payload.subscribe({ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -29,6 +30,7 @@ const source_payload_string = source_payload.pipe( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // Declare target Services && Observables (Using MongoDB Storage) Simulating Partial Logs 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const target_syncrhonize = new MessageSyncrhonizationService() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const target_payload: Observable<BaseMessage> = stream.stream().pipe(take(2)) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -37,7 +39,9 @@ const target_incoming = new IncomingMessageService() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 target_payload.subscribe({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     next: (data) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         target_payload_subject.next(<BaseMessage>data) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    error: e => console.error(e), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    complete: () => { `Target Payload Completed` } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const target_payload_string = target_payload.pipe( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     map((data) => { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -106,38 +110,26 @@ let settings: MessageSynchronisationServiceSetting = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }  //LogSetting & {tags:string[] }   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+const triggerSync = timer(5000).pipe(map( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    (value) => String(value) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /* -------- SYNCHRONIZATION --------- */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-async function initializeData(): Promise<void> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+function initializeData() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     source_incoming.init(source_dataSet) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     target_incoming.init(target_dataSet) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    setTimeout(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 4500) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// initializeData().then(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//     source_synchronize.init(settings) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// }).then(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//     let stream: Observable<BaseMessage> = new MessageSyncrhonizationService().subscribe(source_payload_string) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//     stream.subscribe({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//         next: (msgToBeSynced) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//             target_payload_subject.next(msgToBeSynced) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//             console.log(msgToBeSynced.header.messageID) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//     }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-/*  Run this code to put some data into the database. 4 in File storage and 2 in Mongo */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 initializeData() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-/*  Type 1 synchronization */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-/* Please note that this operation assumes that there's already existing data in the designated storage place. It still cannot perform real-time live streaming dynamically 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-when there is a streaming occuring.  */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 source_synchronize.init(settings).then(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    source_synchronize.subscribe(source_payload_string).subscribe({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        next: (msgToBeSynchronized) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            target_payload_subject.next(msgToBeSynchronized) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // console.log(`Synchronizing ${msgToBeSynchronized.header.messageID}`) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let sync = source_synchronize.subscribe(triggerSync) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    sync.subscribe({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        next: (msgToBeSynched) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // console.log(`synching ... ${msgToBeSynched.header.messageID}`) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            target_payload_subject.next(msgToBeSynched) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+}) 
			 |