|
@@ -128,8 +128,8 @@ setTimeout(() => {
|
|
|
countdown()
|
|
|
|
|
|
// Convert all the existing cdms into message log
|
|
|
-convertDataInMongo('mongodb://192.168.100.59:27017/primary')
|
|
|
-convertDataInMongo('mongodb+srv://testDB:h1nt1OyXw6QeUnzS@cluster0.29sklte.mongodb.net/secondary')
|
|
|
+convertDataInMongo(primary_storage.customSetting.url)
|
|
|
+convertDataInMongo(secondary_storage.customSetting.url)
|
|
|
|
|
|
// These declaration are for the secondary to log the converted missing data back in it's own collection at their corresponding servers
|
|
|
const dbConnection = mongoose.createConnection("mongodb+srv://testDB:h1nt1OyXw6QeUnzS@cluster0.29sklte.mongodb.net/secondary")
|
|
@@ -152,7 +152,6 @@ function convertDataInMongo(url: string) {
|
|
|
let convertService = new LoggingService()
|
|
|
let dbConnection = mongoose.createConnection(url)
|
|
|
let dataModel = dbConnection.model('genericdata', fingerPrintSchema)
|
|
|
- let messages = dbConnection.model('message', messageSchema)
|
|
|
|
|
|
// Once the data is queried, it will be streamed into the data Subject declared earlier
|
|
|
dataModel.find().then((res) => {
|
|
@@ -166,16 +165,22 @@ function convertDataInMongo(url: string) {
|
|
|
// This is where the transformation happens. The logic is written on the logging service side.
|
|
|
// Once that is done, the transformed data will be saved again bacn in the mongo database in a different databse/collection
|
|
|
data.subscribe((element) => {
|
|
|
- let res = convertService.convertCDMStoMessageLog(element, settings.incomingSource.tags)
|
|
|
- console.log(`Converting fingerprint .... ${res.appData.msgId}`)
|
|
|
- messages.create(res)
|
|
|
+ convertService.convertCDMStoMessageLog(element, settings.incomingSource.tags).then((result: MessageLog) => {
|
|
|
+ console.log(`Converting fingerprint .... ${result.appData.msgId}`)
|
|
|
+ primary.next(result)
|
|
|
+ }).catch((err) => {
|
|
|
+ console.error(err.message)
|
|
|
+ });
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// TO be used by the secondary Subject to convert the message log it receives to complete the synchronization process.
|
|
|
function convertMessageLogToCDMS(args: MessageLog) {
|
|
|
- let converted = secondary_log.convertMessageLogtoCDMS(args)
|
|
|
- dataModel.create(converted)
|
|
|
+ secondary_log.convertMessageLogtoCDMS(args).then((result) => {
|
|
|
+ dataModel.create(result)
|
|
|
+ }).catch((err) => {
|
|
|
+ console.error(err.message)
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
|