Skip to content

Stopping consumers #66

@joelclouddistrict

Description

@joelclouddistrict

Hello,

I'm trying to figure out how to stop consumers manually. I want to handle the onApplicationShutdown NestJS lifecycle hook and, when it is called, stop the SQS consumer and check that there are no jobs running.

This is the SqsModuleOptionsFactory

@Injectable()
export default class SqsOptionsFactory implements SqsModuleOptionsFactory {
 createOptions(): SqsOptions | Promise<SqsOptions> {
    const consumers = []

    consumers.push({
      name: "the-queue-name",
      queueUrl: "the-queue-url",
      region: "the-queue-region",
    })

    return { consumers, producers: [] }
  }
}

Looking at bbc/sqs-consumer I can see the consumer.stop method, how can I retrieve the consumer to call the stop method?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions