|
@@ -12,11 +12,20 @@ export class MessageSyncrhonizationService implements MessageSynchronisationServ
|
|
public async init(settings: MessageSynchronisationServiceSetting): Promise<void> {
|
|
public async init(settings: MessageSynchronisationServiceSetting): Promise<void> {
|
|
this.settings = settings;
|
|
this.settings = settings;
|
|
// Wrap promise so that init must be instantiated with resolve before proceeding with subscribe method
|
|
// Wrap promise so that init must be instantiated with resolve before proceeding with subscribe method
|
|
- let promiseInit : Promise<void> = new Promise((resolve, reject) => {
|
|
|
|
|
|
+ let promiseInit: Promise<void> = new Promise((resolve, reject) => {
|
|
try {
|
|
try {
|
|
- this.sourceSrc.init(settings.incomingSource).then(() => {
|
|
|
|
- this.targetSrc.init(settings.target);
|
|
|
|
- }).then(() => resolve())
|
|
|
|
|
|
+ this.sourceSrc.init(settings.incomingSource).then((data) => {
|
|
|
|
+ if (!data) reject()
|
|
|
|
+ console.log(`File Storage:`)
|
|
|
|
+ data.forEach(e => console.log(e.appLogLocId))
|
|
|
|
+ }).then(() => {
|
|
|
|
+ this.targetSrc.init(settings.target).then((data) => {
|
|
|
|
+ if (!data) reject()
|
|
|
|
+ console.log(`Mongo Storage`)
|
|
|
|
+ data.forEach(e => console.log(e.appLogLocId))
|
|
|
|
+ resolve()
|
|
|
|
+ })
|
|
|
|
+ })
|
|
}
|
|
}
|
|
catch (e) {
|
|
catch (e) {
|
|
console.error(e)
|
|
console.error(e)
|
|
@@ -27,43 +36,35 @@ export class MessageSyncrhonizationService implements MessageSynchronisationServ
|
|
|
|
|
|
public subscribe(obs: Observable<string>): Observable<any> {
|
|
public subscribe(obs: Observable<string>): Observable<any> {
|
|
let subjectOutput = new Subject()
|
|
let subjectOutput = new Subject()
|
|
- obs.subscribe({
|
|
|
|
- next: element => {
|
|
|
|
- let data = JSON.parse(element)
|
|
|
|
- console.log(data.header.messageID)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
|
|
// filter all source tags[0] log data
|
|
// filter all source tags[0] log data
|
|
- let set1 = this.sourceSrc.filter(
|
|
|
|
- { msgTag: this.settings.incomingSource.tags[0] })
|
|
|
|
- let set2 = this.targetSrc.filter(
|
|
|
|
- { msgTag: this.settings.target.tags[0] }
|
|
|
|
- )
|
|
|
|
- this.compareResult(set1, set2).then((data) => {
|
|
|
|
- data.forEach(element => {
|
|
|
|
- subjectOutput.next(element)
|
|
|
|
- })
|
|
|
|
- })
|
|
|
|
|
|
+ let set1 = this.sourceSrc.filter({ msgTag: this.settings.incomingSource.tags[0] })
|
|
|
|
+ set1.then((data) => console.log(data.length))
|
|
|
|
+ let set2 = this.targetSrc.filter({ msgTag: this.settings.target.tags[0] })
|
|
|
|
+ set2.then((data) => console.log(data.length))
|
|
|
|
+
|
|
|
|
+ // this.compareResult(set1, set2).then((data) => {
|
|
|
|
+ // data.forEach(element => {
|
|
|
|
+ // subjectOutput.next(element)
|
|
|
|
+ // })
|
|
|
|
+ // })
|
|
|
|
|
|
return subjectOutput.asObservable()
|
|
return subjectOutput.asObservable()
|
|
}
|
|
}
|
|
|
|
|
|
// compare results and return differences
|
|
// compare results and return differences
|
|
- private async compareResult(args: Promise<any>, args2: Promise<any>): Promise<any[]> {
|
|
|
|
- let dataset3
|
|
|
|
- await args.then((data) => {
|
|
|
|
- console.log(data)
|
|
|
|
- args2.then((data2) => {
|
|
|
|
- data.forEach((element) => {
|
|
|
|
- data2.forEach((element2) => {
|
|
|
|
- dataset3 = '' // missing messages
|
|
|
|
- })
|
|
|
|
- })
|
|
|
|
- })
|
|
|
|
|
|
+ private async compareResult(args: Promise<any>, args2: Promise<any>): Promise<any> {
|
|
|
|
+ let arr1 = []
|
|
|
|
+ let arr2 = []
|
|
|
|
+ args.then((element) => {
|
|
|
|
+ arr1.push(element)
|
|
})
|
|
})
|
|
-
|
|
|
|
- return dataset3
|
|
|
|
|
|
+ args2.then((element) => {
|
|
|
|
+ arr2.push(element)
|
|
|
|
+ })
|
|
|
|
+ console.log(arr1)
|
|
|
|
+ console.log(arr2)
|
|
|
|
+ return arr1
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|