Skip to content

Commit

Permalink
🥅 soft queue purging
Browse files Browse the repository at this point in the history
  • Loading branch information
karafra committed Jul 18, 2022
1 parent bec6544 commit 1c6f09a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/services/amqp/amqp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import { Injectable } from '@nestjs/common';
@Injectable()
export class AmqpService {
private lastDispatch: number = Date.now();

public constructor(
@InjectAmqpClient() private readonly amqpClient: AmqpClient,
) {}

public async purgeQueue(queueName: string): Promise<void> {
const channel = await this.amqpClient.channel();
await channel.queuePurge(queueName);
await channel.close('Service stopped', 320);
try {
await channel.queuePurge(queueName);
} catch {
} finally {
await channel.close('Service stopped', 320);
}
}

public async popFromQueue<T>(queueName: string): Promise<T> {
Expand Down

0 comments on commit 1c6f09a

Please sign in to comment.