mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-23 17:08:44 -06:00
feat: enhance message processing with retry logic for error handling
This commit is contained in:
parent
89d4d341f6
commit
05886ec684
@ -1,6 +1,6 @@
|
||||
import { Logger } from '@config/logger.config';
|
||||
import { BaileysEventMap, MessageUpsertType, proto } from 'baileys';
|
||||
import { catchError, concatMap, EMPTY, from, Subject, Subscription, tap } from 'rxjs';
|
||||
import { catchError, concatMap, delay, EMPTY, from, retryWhen, Subject, Subscription, take, tap } from 'rxjs';
|
||||
|
||||
type MessageUpsertPayload = BaileysEventMap['messages.upsert'];
|
||||
type MountProps = {
|
||||
@ -25,7 +25,15 @@ export class BaileysMessageProcessor {
|
||||
this.processorLogs.log(`Processing batch of ${messages.length} messages`);
|
||||
}),
|
||||
concatMap(({ messages, type, requestId, settings }) =>
|
||||
from(onMessageReceive({ messages, type, requestId }, settings)),
|
||||
from(onMessageReceive({ messages, type, requestId }, settings)).pipe(
|
||||
retryWhen((errors) =>
|
||||
errors.pipe(
|
||||
tap((error) => this.processorLogs.warn(`Retrying message batch due to error: ${error.message}`)),
|
||||
delay(1000), // 1 segundo de delay
|
||||
take(3), // Máximo 3 tentativas
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
catchError((error) => {
|
||||
this.processorLogs.error(`Error processing message batch: ${error}`);
|
||||
|
Loading…
Reference in New Issue
Block a user