fix ad validation after matcher ad creation

This commit is contained in:
Sylvain Briat 2023-12-07 11:11:52 +01:00
parent 976a3c3779
commit f69e8a95f1
3 changed files with 31 additions and 19 deletions

View File

@ -5,16 +5,18 @@ export const SERVICE_NAME = 'ad';
export const GRPC_PACKAGE_NAME = 'ad'; export const GRPC_PACKAGE_NAME = 'ad';
export const GRPC_SERVICE_NAME = 'AdService'; export const GRPC_SERVICE_NAME = 'AdService';
// messaging // messaging output
export const AD_CREATED_ROUTING_KEY = 'ad.created'; export const AD_CREATED_ROUTING_KEY = 'ad.created';
// messaging input
export const MATCHER_AD_CREATED_MESSAGE_HANDLER = 'matcherAdCreated'; export const MATCHER_AD_CREATED_MESSAGE_HANDLER = 'matcherAdCreated';
export const MATCHER_AD_CREATED_ROUTING_KEY = 'matcher.ad.created'; export const MATCHER_AD_CREATED_ROUTING_KEY = 'matcher-ad.created';
export const MATCHER_AD_CREATED_QUEUE = 'matcher-ad-created'; export const MATCHER_AD_CREATED_QUEUE = 'ad.matcher-ad.created';
export const MATCHER_AD_CREATION_FAILED_MESSAGE_HANDLER = export const MATCHER_AD_CREATION_FAILED_MESSAGE_HANDLER =
'matcherAdCreationFailed'; 'matcherAdCreationFailed';
export const MATCHER_AD_CREATION_FAILED_ROUTING_KEY = export const MATCHER_AD_CREATION_FAILED_ROUTING_KEY =
'matcher.ad.creation.failed'; 'matcher-ad.creation-failed';
export const MATCHER_AD_CREATION_FAILED_QUEUE = 'matcher-ad-creation-failed'; export const MATCHER_AD_CREATION_FAILED_QUEUE = 'ad.matcher-ad.creation-failed';
// configuration // configuration
export const SERVICE_CONFIGURATION_SET_QUEUE = 'ad-configuration-set'; export const SERVICE_CONFIGURATION_SET_QUEUE = 'ad-configuration-set';

View File

@ -13,6 +13,7 @@ export class MatcherAdCreatedMessageHandler {
name: MATCHER_AD_CREATED_MESSAGE_HANDLER, name: MATCHER_AD_CREATED_MESSAGE_HANDLER,
}) })
public async matcherAdCreated(message: string) { public async matcherAdCreated(message: string) {
try {
const matcherAdCreatedIntegrationEvent: MatcherAdCreatedIntegrationEvent = const matcherAdCreatedIntegrationEvent: MatcherAdCreatedIntegrationEvent =
JSON.parse(message); JSON.parse(message);
await this.commandBus.execute( await this.commandBus.execute(
@ -20,5 +21,9 @@ export class MatcherAdCreatedMessageHandler {
id: matcherAdCreatedIntegrationEvent.id, 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
}
} }
} }

View File

@ -13,6 +13,7 @@ export class MatcherAdCreationFailedMessageHandler {
name: MATCHER_AD_CREATION_FAILED_MESSAGE_HANDLER, name: MATCHER_AD_CREATION_FAILED_MESSAGE_HANDLER,
}) })
public async matcherAdCreationFailed(message: string) { public async matcherAdCreationFailed(message: string) {
try {
const matcherAdCreationFailedIntegrationEvent: MatcherAdCreationFailedIntegrationEvent = const matcherAdCreationFailedIntegrationEvent: MatcherAdCreationFailedIntegrationEvent =
JSON.parse(message); JSON.parse(message);
await this.commandBus.execute( await this.commandBus.execute(
@ -20,5 +21,9 @@ export class MatcherAdCreationFailedMessageHandler {
id: matcherAdCreationFailedIntegrationEvent.id, 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
}
} }
} }