From 11705aa84b7368d4ae479c63dc5018852c48bb7f Mon Sep 17 00:00:00 2001 From: Eric Richardson Date: Mon, 15 Jan 2024 11:41:40 -0500 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20set=20autoaccept=20to=20?= =?UTF-8?q?false?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit routes messages to DLQ with reject method. also consistently use all lower case for logs --- src/artemis/artemis.service.ts | 21 ++++++++++++------- .../models/offline-tx.model.ts | 1 - 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/artemis/artemis.service.ts b/src/artemis/artemis.service.ts index 0932bc4b..ee6f105d 100644 --- a/src/artemis/artemis.service.ts +++ b/src/artemis/artemis.service.ts @@ -99,18 +99,18 @@ export class ArtemisService implements OnApplicationShutdown { } private receiverOptions(listenOn: QueueName): ReceiverOptions { - /* istanbul ignore next: not worth mocking the lib callbacks */ + /* istanbul ignore next: not worth mocking the lib callbacks for a log */ const onSessionError = (context: EventContext): void => { const sessionError = context?.session?.error; this.logger.error( - `A session error occurred for receiver "${listenOn}": ${sessionError ?? 'unknown error'}` + `session error occurred for receiver "${listenOn}": ${sessionError ?? 'unknown error'}` ); }; return { name: `${listenOn}`, credit_window: 1, - autoaccept: true, + autoaccept: false, autosettle: false, source: { address: listenOn, @@ -155,7 +155,7 @@ export class ArtemisService implements OnApplicationShutdown { receiver.on(ReceiverEvents.message, async (context: EventContext) => { this.logger.debug(`received message ${listenOn}`); - /* istanbul ignore next: message will be unacknowledgeable without this */ + /* istanbul ignore next: message cannot be acknowledge without `delivery` methods */ if (!context.delivery) { throw new AppInternalError('message received without delivery methods'); } @@ -165,8 +165,15 @@ export class ArtemisService implements OnApplicationShutdown { const validationErrors = await validate(model); if (validationErrors.length) { this.logger.error( - `Validation errors for "${listenOn}": ${JSON.stringify(validationErrors)}` + `validation errors for "${listenOn}": ${JSON.stringify(validationErrors)}` ); + + context.delivery.reject({ + condition: 'validation error', + description: `message was deemed invalid for model: ${Model.name}`, + }); + + return; } try { @@ -184,7 +191,7 @@ export class ArtemisService implements OnApplicationShutdown { context.delivery.reject({ condition: 'processing error', - description: `Error processing message: ${message}`, + description: `error processing message: ${message}`, }); } } @@ -192,7 +199,7 @@ export class ArtemisService implements OnApplicationShutdown { receiver.on(ReceiverEvents.receiverError, (context: EventContext) => { const receiverError = context?.receiver?.error; - this.logger.error(`An error occurred for receiver "${listenOn}": ${receiverError}`); + this.logger.error(`an error occurred for receiver "${listenOn}": ${receiverError}`); }); } diff --git a/src/offline-submitter/models/offline-tx.model.ts b/src/offline-submitter/models/offline-tx.model.ts index 3ecbbcdc..ff552e91 100644 --- a/src/offline-submitter/models/offline-tx.model.ts +++ b/src/offline-submitter/models/offline-tx.model.ts @@ -24,7 +24,6 @@ export class OfflineTxModel { @ApiProperty({ description: 'The signature for the transaction', }) - @IsOptional() @IsString() signature: string;