Skip to content

Commit

Permalink
feat: 🎸 set autoaccept to false
Browse files Browse the repository at this point in the history
routes messages to DLQ with reject method. also consistently use all
lower case for logs
  • Loading branch information
polymath-eric committed Jan 16, 2024
1 parent aaf685b commit 11705aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
21 changes: 14 additions & 7 deletions src/artemis/artemis.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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');
}
Expand All @@ -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 {
Expand All @@ -184,15 +191,15 @@ export class ArtemisService implements OnApplicationShutdown {

context.delivery.reject({
condition: 'processing error',
description: `Error processing message: ${message}`,
description: `error processing message: ${message}`,
});
}
}
});

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}`);
});
}

Expand Down
1 change: 0 additions & 1 deletion src/offline-submitter/models/offline-tx.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class OfflineTxModel {
@ApiProperty({
description: 'The signature for the transaction',
})
@IsOptional()
@IsString()
signature: string;

Expand Down

0 comments on commit 11705aa

Please sign in to comment.