From f69e8a95f1357fe7332cd0f4bbe401a57114b020 Mon Sep 17 00:00:00 2001 From: Sylvain Briat Date: Thu, 7 Dec 2023 11:11:52 +0100 Subject: [PATCH 1/2] fix ad validation after matcher ad creation --- src/app.constants.ts | 12 +++++++----- .../matcher-ad-created.message-handler.ts | 19 ++++++++++++------- ...cher-ad-creation-failed.message-handler.ts | 19 ++++++++++++------- 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/app.constants.ts b/src/app.constants.ts index a29cf71..0592c17 100644 --- a/src/app.constants.ts +++ b/src/app.constants.ts @@ -5,16 +5,18 @@ export const SERVICE_NAME = 'ad'; export const GRPC_PACKAGE_NAME = 'ad'; export const GRPC_SERVICE_NAME = 'AdService'; -// messaging +// messaging output export const AD_CREATED_ROUTING_KEY = 'ad.created'; + +// messaging input export const MATCHER_AD_CREATED_MESSAGE_HANDLER = 'matcherAdCreated'; -export const MATCHER_AD_CREATED_ROUTING_KEY = 'matcher.ad.created'; -export const MATCHER_AD_CREATED_QUEUE = 'matcher-ad-created'; +export const MATCHER_AD_CREATED_ROUTING_KEY = 'matcher-ad.created'; +export const MATCHER_AD_CREATED_QUEUE = 'ad.matcher-ad.created'; export const MATCHER_AD_CREATION_FAILED_MESSAGE_HANDLER = 'matcherAdCreationFailed'; export const MATCHER_AD_CREATION_FAILED_ROUTING_KEY = - 'matcher.ad.creation.failed'; -export const MATCHER_AD_CREATION_FAILED_QUEUE = 'matcher-ad-creation-failed'; + 'matcher-ad.creation-failed'; +export const MATCHER_AD_CREATION_FAILED_QUEUE = 'ad.matcher-ad.creation-failed'; // configuration export const SERVICE_CONFIGURATION_SET_QUEUE = 'ad-configuration-set'; diff --git a/src/modules/ad/interface/message-handlers/matcher-ad-created.message-handler.ts b/src/modules/ad/interface/message-handlers/matcher-ad-created.message-handler.ts index 9ed1e4a..eb8f44e 100644 --- a/src/modules/ad/interface/message-handlers/matcher-ad-created.message-handler.ts +++ b/src/modules/ad/interface/message-handlers/matcher-ad-created.message-handler.ts @@ -13,12 +13,17 @@ export class MatcherAdCreatedMessageHandler { name: MATCHER_AD_CREATED_MESSAGE_HANDLER, }) public async matcherAdCreated(message: string) { - const matcherAdCreatedIntegrationEvent: MatcherAdCreatedIntegrationEvent = - JSON.parse(message); - await this.commandBus.execute( - new ValidateAdCommand({ - id: matcherAdCreatedIntegrationEvent.id, - }), - ); + try { + const matcherAdCreatedIntegrationEvent: MatcherAdCreatedIntegrationEvent = + JSON.parse(message); + await this.commandBus.execute( + new ValidateAdCommand({ + id: matcherAdCreatedIntegrationEvent.id, + }), + ); + } catch (error: any) { + // do not throw error to acknowledge incoming message + // error handling should be done in the command handler, if relevant + } } } diff --git a/src/modules/ad/interface/message-handlers/matcher-ad-creation-failed.message-handler.ts b/src/modules/ad/interface/message-handlers/matcher-ad-creation-failed.message-handler.ts index 05e3691..8b0fdb0 100644 --- a/src/modules/ad/interface/message-handlers/matcher-ad-creation-failed.message-handler.ts +++ b/src/modules/ad/interface/message-handlers/matcher-ad-creation-failed.message-handler.ts @@ -13,12 +13,17 @@ export class MatcherAdCreationFailedMessageHandler { name: MATCHER_AD_CREATION_FAILED_MESSAGE_HANDLER, }) public async matcherAdCreationFailed(message: string) { - const matcherAdCreationFailedIntegrationEvent: MatcherAdCreationFailedIntegrationEvent = - JSON.parse(message); - await this.commandBus.execute( - new InvalidateAdCommand({ - id: matcherAdCreationFailedIntegrationEvent.id, - }), - ); + try { + const matcherAdCreationFailedIntegrationEvent: MatcherAdCreationFailedIntegrationEvent = + JSON.parse(message); + await this.commandBus.execute( + new InvalidateAdCommand({ + id: matcherAdCreationFailedIntegrationEvent.id, + }), + ); + } catch (error: any) { + // do not throw error to acknowledge incoming message + // error handling should be done in the command handler, if relevant + } } } From ee0a2cb386b14df5308b227f92b0bd23de65db99 Mon Sep 17 00:00:00 2001 From: Sylvain Briat Date: Thu, 7 Dec 2023 11:11:59 +0100 Subject: [PATCH 2/2] 2.4.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0e0cd4c..36dad6d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mobicoop/ad", - "version": "2.4.0", + "version": "2.4.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@mobicoop/ad", - "version": "2.4.0", + "version": "2.4.1", "license": "AGPL", "dependencies": { "@grpc/grpc-js": "^1.9.11", diff --git a/package.json b/package.json index ebfc281..3ba70bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mobicoop/ad", - "version": "2.4.0", + "version": "2.4.1", "description": "Mobicoop V3 Ad", "author": "sbriat", "private": true,