Skip to content
This repository was archived by the owner on Dec 19, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
KAFKA_URL=kafka:9092

2 changes: 1 addition & 1 deletion src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion src/issue-creator/issue-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export abstract class IssueReporter {
console.log("CREATED ISSUE", issueID);
return issueID;
} catch (error) {
throw new Error(error);
console.log(error);
}
}

Expand Down
15 changes: 13 additions & 2 deletions src/log-receiver/log-receiver.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class LogReceiverService implements OnModuleInit {
initKafka() {
this.kafkaUrl = this.configService.get<string>(
'KAFKA_URL',
'localhost:9092',
'1.1.1.1:9092',
);
(this.kafka = new Kafka({
clientId: 'issue-creator',
Expand Down Expand Up @@ -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
*/
Expand All @@ -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
}
}
}
},
});
Expand Down