|
1 | 1 | import { Injectable } from '@nestjs/common'; |
2 | 2 | import {ChangePasswordDto} from "./dto/change-password.dto"; |
3 | 3 | import {InjectQueue} from "@nestjs/bullmq"; |
4 | | -import {Job, Queue,QueueEvents} from 'bullmq' |
| 4 | +import { Queue,QueueEvents} from 'bullmq' |
| 5 | +import { ConfigService } from '@nestjs/config'; |
5 | 6 | @Injectable() |
6 | 7 | export class PasswdService { |
7 | | - constructor(@InjectQueue('backend') private backendQueue: Queue){} |
8 | 8 |
|
| 9 | + constructor(private readonly configService:ConfigService){} |
9 | 10 | async change(passwd:ChangePasswordDto) { |
10 | | - const queueEvents = new QueueEvents('backend',{connection: {host:'redis',port:6379}}) |
11 | | - const job=await this.backendQueue.add('CHANGEPWD',passwd) |
| 11 | + const redisConfig={host:this.configService.get('redis.host'),port:this.configService.get('redis.port')} |
| 12 | + const queue=new Queue(this.configService.get('nameQueue'),{connection:redisConfig}) |
| 13 | + const queueEvents = new QueueEvents(this.configService.get('nameQueue'),{connection: redisConfig}) |
| 14 | + const job=await queue.add('CHANGEPWD',passwd) |
12 | 15 | queueEvents.on('failed',(errors)=>{ |
13 | 16 | console.log(errors) |
14 | 17 | }) |
15 | | - return await job.waitUntilFinished(queueEvents) |
16 | | - |
17 | | - |
| 18 | + return await job.waitUntilFinished(queueEvents,30000) |
18 | 19 | } |
19 | 20 | } |
20 | 21 |
|
|
0 commit comments