|
@@ -1,7 +1,7 @@
|
|
import { resolve } from "path";
|
|
import { resolve } from "path";
|
|
import { Observable, map, Subject, takeUntil, take } from "rxjs";
|
|
import { Observable, map, Subject, takeUntil, take } from "rxjs";
|
|
import { BaseMessage } from "../dependencies/fisappmessagejsutilty/dependencies/dependencies";
|
|
import { BaseMessage } from "../dependencies/fisappmessagejsutilty/dependencies/dependencies";
|
|
-import { LogSetting } from "../dependencies/fisloggingservice/type/datatype";
|
|
|
|
|
|
+import { LogSetting, MessageLog } from "../dependencies/fisloggingservice/type/datatype";
|
|
import { AcknowledgementService } from "../services/acknowledgement.service";
|
|
import { AcknowledgementService } from "../services/acknowledgement.service";
|
|
import { IncomingMessageService } from "../services/incomingMessage.service";
|
|
import { IncomingMessageService } from "../services/incomingMessage.service";
|
|
import { MessageSyncrhonizationService } from "../services/synchronization.service";
|
|
import { MessageSyncrhonizationService } from "../services/synchronization.service";
|
|
@@ -11,11 +11,18 @@ import { StreamingService } from "./test-streamOBS";
|
|
|
|
|
|
/* Pre - Defined Data && Settings */
|
|
/* Pre - Defined Data && Settings */
|
|
const stream = new StreamingService()
|
|
const stream = new StreamingService()
|
|
|
|
+
|
|
// Declare source Services && Observables (Using File Storage) Simulating Full Logs
|
|
// Declare source Services && Observables (Using File Storage) Simulating Full Logs
|
|
const source_synchronize = new MessageSyncrhonizationService()
|
|
const source_synchronize = new MessageSyncrhonizationService()
|
|
-const source_payload: Observable<BaseMessage> = stream.stream()
|
|
|
|
|
|
+const source_payload: Observable<BaseMessage> = stream.stream().pipe()
|
|
const source_incoming = new IncomingMessageService()
|
|
const source_incoming = new IncomingMessageService()
|
|
-const source_acknowledge = new AcknowledgementService()
|
|
|
|
|
|
+const source_payload_subject: Subject<BaseMessage> = new Subject()
|
|
|
|
+source_payload.subscribe({
|
|
|
|
+ next: (data) => {
|
|
|
|
+ source_payload_subject.next(data)
|
|
|
|
+ // console.log(data)
|
|
|
|
+ }
|
|
|
|
+})
|
|
const source_payload_string = source_payload.pipe(
|
|
const source_payload_string = source_payload.pipe(
|
|
map((data) => {
|
|
map((data) => {
|
|
return JSON.stringify(data);
|
|
return JSON.stringify(data);
|
|
@@ -23,25 +30,29 @@ const source_payload_string = source_payload.pipe(
|
|
)
|
|
)
|
|
|
|
|
|
// Declare target Services && Observables (Using MongoDB Storage) Simulating Partial Logs
|
|
// 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))
|
|
const target_payload: Observable<BaseMessage> = stream.stream().pipe(take(2))
|
|
const target_payload_subject: Subject<BaseMessage> = new Subject()
|
|
const target_payload_subject: Subject<BaseMessage> = new Subject()
|
|
-target_payload.subscribe(
|
|
|
|
- {
|
|
|
|
- next: (data) => {
|
|
|
|
- target_payload_subject.next(data)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-)
|
|
|
|
const target_incoming = new IncomingMessageService()
|
|
const target_incoming = new IncomingMessageService()
|
|
-const target_syncrhonize = new MessageSyncrhonizationService()
|
|
|
|
-const target_acknowledge = new AcknowledgementService()
|
|
|
|
|
|
+target_payload.subscribe({
|
|
|
|
+ next: (data) => {
|
|
|
|
+ target_payload_subject.next(<BaseMessage>data)
|
|
|
|
+ }
|
|
|
|
+})
|
|
const target_payload_string = target_payload.pipe(
|
|
const target_payload_string = target_payload.pipe(
|
|
map((data) => {
|
|
map((data) => {
|
|
return JSON.stringify(data);
|
|
return JSON.stringify(data);
|
|
}),
|
|
}),
|
|
)
|
|
)
|
|
|
|
+// testing to see if data is sent in
|
|
|
|
+target_payload_subject.subscribe({
|
|
|
|
+ next: element => {
|
|
|
|
+ // console.log(element)
|
|
|
|
+ // Missing MessageLog Data is sent in
|
|
|
|
+ }
|
|
|
|
+})
|
|
|
|
|
|
-// Decalre Source Storage
|
|
|
|
|
|
+// Declare Source Storage
|
|
let source_storage: LogSetting = {
|
|
let source_storage: LogSetting = {
|
|
storage: "File",
|
|
storage: "File",
|
|
setting: {
|
|
setting: {
|
|
@@ -55,7 +66,7 @@ let source_dataSet: LogSetting & { incomingObservable: Observable<BaseMessage> }
|
|
storage: source_storage.storage,
|
|
storage: source_storage.storage,
|
|
setting: source_storage.setting,
|
|
setting: source_storage.setting,
|
|
customSetting: source_storage.customSetting,
|
|
customSetting: source_storage.customSetting,
|
|
- incomingObservable: source_payload
|
|
|
|
|
|
+ incomingObservable: source_payload_subject
|
|
}
|
|
}
|
|
|
|
|
|
//Declare Target Storage
|
|
//Declare Target Storage
|
|
@@ -74,11 +85,12 @@ let target_storage: LogSetting = {
|
|
collection: "log",
|
|
collection: "log",
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
let target_dataSet: LogSetting & { incomingObservable: Observable<BaseMessage> } = {
|
|
let target_dataSet: LogSetting & { incomingObservable: Observable<BaseMessage> } = {
|
|
storage: target_storage.storage,
|
|
storage: target_storage.storage,
|
|
setting: target_storage.setting,
|
|
setting: target_storage.setting,
|
|
customSetting: target_storage.customSetting,
|
|
customSetting: target_storage.customSetting,
|
|
- incomingObservable: target_payload
|
|
|
|
|
|
+ incomingObservable: target_payload_subject
|
|
}
|
|
}
|
|
|
|
|
|
// Combine source and target storage to form MessageSynchronisationServiceSetting
|
|
// Combine source and target storage to form MessageSynchronisationServiceSetting
|
|
@@ -94,94 +106,35 @@ let settings: MessageSynchronisationServiceSetting = {
|
|
} //LogSetting & {tags:string[] }
|
|
} //LogSetting & {tags:string[] }
|
|
}
|
|
}
|
|
|
|
|
|
-setTimeout(()=>{
|
|
|
|
- target_payload_subject.next(
|
|
|
|
- <BaseMessage>{
|
|
|
|
- "header": {
|
|
|
|
- "messageType": "Command",
|
|
|
|
- "messageID": "ab05f310-f3c5-4fd0-9af1-15cda97b4444",
|
|
|
|
- "messageName": "Command",
|
|
|
|
- "dateCreated": "2023-02-13T03:33:58.746Z",
|
|
|
|
- "isAggregate": false,
|
|
|
|
- "dataSourceTiming": "",
|
|
|
|
- "serviceId": "",
|
|
|
|
- "userId": "",
|
|
|
|
- "requesterId": "Generatede203a86a-c99e-460e-95ff-f2dc7f484a7d",
|
|
|
|
- "messageProducerInformation": {
|
|
|
|
- "origin": {
|
|
|
|
- "userApplication": {
|
|
|
|
- "userAppId": "FisAppID/Name",
|
|
|
|
- "userAppName": "Client"
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- "components": "Presentation"
|
|
|
|
- },
|
|
|
|
- "security": {
|
|
|
|
- "ucpId": "GeneratedFromMessageSync"
|
|
|
|
- },
|
|
|
|
- "messageDataLocation": {
|
|
|
|
- "isEmbaded": true
|
|
|
|
- },
|
|
|
|
- "messageDataFormat": {
|
|
|
|
- "dataFormat": "Json"
|
|
|
|
- },
|
|
|
|
- "requestExecutionMode": 0,
|
|
|
|
- "resquestTimeOut": 0,
|
|
|
|
- "command": "New"
|
|
|
|
- },
|
|
|
|
- "data": {
|
|
|
|
- "header": "fa29074d-9718-4aba-9999-0001",
|
|
|
|
- "data": {
|
|
|
|
- "appLogLocId": "fa29074d-9718-4aba-9999-0001",
|
|
|
|
- "appData": {
|
|
|
|
- "msgId": "6c162cd3-d42d-4ab4-8882-0001",
|
|
|
|
- "msgLogDateTime": "2022-12-06T15:01:46.987Z",
|
|
|
|
- "msgDateTime": "2022-12-06T08:50:33.809Z",
|
|
|
|
- "msgTag": [
|
|
|
|
- "oval",
|
|
|
|
- "likable"
|
|
|
|
- ],
|
|
|
|
- "msgPayload": "Molestias facilis iusto similique iste voluptas facere. Alias est sequi. Quos consequatur temporibus blanditiis numquam vel. Eos repellat eaque. Voluptatibus optio optio magni eveniet. Quidem architecto esse aut sint neque error magnam perspiciatis."
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- )
|
|
|
|
-},2000)
|
|
|
|
|
|
|
|
/* -------- SYNCHRONIZATION --------- */
|
|
/* -------- SYNCHRONIZATION --------- */
|
|
-async function initializeData(): Promise<void> {
|
|
|
|
|
|
+function initializeData() {
|
|
source_incoming.init(source_dataSet)
|
|
source_incoming.init(source_dataSet)
|
|
target_incoming.init(target_dataSet)
|
|
target_incoming.init(target_dataSet)
|
|
- return
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-/* Run this code to pluck some data into the database. 4 in File storage and 2 in Mongo */
|
|
|
|
|
|
+/* Run this code to put some data into the database. 4 in File storage and 2 in Mongo */
|
|
// initializeData()
|
|
// initializeData()
|
|
|
|
|
|
-
|
|
|
|
-/* Testing to wrap everything into a promise */
|
|
|
|
-// initializeData().then(() => {
|
|
|
|
-// source_synchronize.init(settings).then(() => {
|
|
|
|
-// source_synchronize.subscribe(source_payload_string).subscribe({
|
|
|
|
-// next: msgToBeSynchronized => {
|
|
|
|
-// target_payload_subject.next(msgToBeSynchronized)
|
|
|
|
-// console.log(msgToBeSynchronized) // It does log missing items
|
|
|
|
-// }
|
|
|
|
-// })
|
|
|
|
-// })
|
|
|
|
-// })
|
|
|
|
-
|
|
|
|
/* Type 1 synchronization */
|
|
/* 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
|
|
/* 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. */
|
|
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(msgToBeSynchronized) // It does log missing items
|
|
|
|
+// }
|
|
|
|
+// })
|
|
|
|
+// })
|
|
|
|
+
|
|
source_synchronize.init(settings).then(() => {
|
|
source_synchronize.init(settings).then(() => {
|
|
- source_synchronize.subscribe(source_payload_string).subscribe({
|
|
|
|
- next: msgToBeSynchronized => {
|
|
|
|
- target_payload_subject.next(msgToBeSynchronized)
|
|
|
|
- // console.log(msgToBeSynchronized) // It does log missing items
|
|
|
|
|
|
+ let stream = source_synchronize.subscribe(source_payload_string) // this returns an observable declared with stream
|
|
|
|
+ stream.subscribe({
|
|
|
|
+ next: (messageToBeSync) => {
|
|
|
|
+ target_payload_subject.next(messageToBeSync)
|
|
|
|
+ // console.log(messageToBeSync)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
})
|
|
})
|
|
-
|
|
|
|
-// Doesnt seem like they do anything
|
|
|
|
|
|
+
|