diff --git a/.env b/.env index 28ad2dd..5ab4f32 100644 --- a/.env +++ b/.env @@ -10,5 +10,15 @@ FRONTEND_PRICE_SERVICE_URL=http://localhost:4300/ FRONTEND_ACCOUNT_SERVICE_URL=http://localhost:4100/ FRONTEND_MONITORING_SERVICE_URL=http://localhost:4200/ +ID_DB_SERVICE= +ID_PRICE_SERVICE= +ID_ACCOUNT_SERVICE= + +ID_CPU_MONITOR= +ID_RESPONSE_MONITOR= +ID_ISSUE_CREATOR= +ID_BACKEND_API= + BACKEND_COMPONENT_ID = 5d340f2394eaa004 -KAFKA_URL=localhost:9092 \ No newline at end of file +KAFKA_URL=kafka:9092 + diff --git a/src/app.module.ts b/src/app.module.ts index aa53134..a4c5f56 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -11,7 +11,7 @@ import { ConfigModule } from '@nestjs/config'; @Module({ imports: [ HttpModule, - MongooseModule.forRoot('mongodb://localhost:27017/logDatabase'), + MongooseModule.forRoot('mongodb://db:27017/logDatabase'), MongooseModule.forFeature([ { name: 'logs', schema: LogsSchema }, { name: 'service', schema: ServiceSchema } diff --git a/src/issue-creator/issue-reporter.ts b/src/issue-creator/issue-reporter.ts index 40d0147..457994e 100644 --- a/src/issue-creator/issue-reporter.ts +++ b/src/issue-creator/issue-reporter.ts @@ -36,7 +36,7 @@ export abstract class IssueReporter { console.log("CREATED ISSUE", issueID); return issueID; } catch (error) { - throw new Error(error); + console.log(error); } } diff --git a/src/log-receiver/log-receiver.service.ts b/src/log-receiver/log-receiver.service.ts index f805b7f..453344d 100644 --- a/src/log-receiver/log-receiver.service.ts +++ b/src/log-receiver/log-receiver.service.ts @@ -69,7 +69,7 @@ export class LogReceiverService implements OnModuleInit { initKafka() { this.kafkaUrl = this.configService.get( 'KAFKA_URL', - 'localhost:9092', + '1.1.1.1:9092', ); (this.kafka = new Kafka({ clientId: 'issue-creator', @@ -216,6 +216,9 @@ export class LogReceiverService implements OnModuleInit { /** * Connecting to kafka instance and begin consuming * incoming messages are saved to the collection logs in the mongodb + * + * If error status is 401 or 406 message is from not registered service + * then message is discarded, else error is thrown again and the message stays in the MQ * * Consumer is subscribed to the logs topic at the kafka instance */ @@ -227,7 +230,15 @@ export class LogReceiverService implements OnModuleInit { eachMessage: async ({ topic, partition, message }) => { if (message.value != null) { const log: LogMessageFormat = JSON.parse(message.value.toString()); - await this.handleLogMessage(log); + try { + await this.handleLogMessage(log); + } catch (error) { + if (error.status === 401 || 406) { + console.error(error) + } else { + throw error + } + } } }, });