ssut / nestjs-sqs

A project to make SQS easier to use within NestJS, with decorator-based handling and seamless NestJS-way integration.
MIT License
214 stars 53 forks source link

feat: Add multi instance for consumer #43

Open draganemilian opened 1 year ago

udithrooverr commented 1 year ago

merge soon

throberto commented 11 months ago

eagerly waiting for this...

ciandt-JEFFERSONSILVERIO commented 10 months ago

Any news?

rbonestell commented 6 months ago

Isn't this a non-issue if you simply use different names for the consumers you implement? Providing the same configuration for N instances of consumers, each with different names, would accomplish the same goal:

SqsModule.registerAsync({
    imports: [ConfigModule],
    useFactory: (configService: ConfigService, logger: Logger) => {
        const region = configService.get('AWS.DEFAULT_REGION');
        const queueUrl = configService.get('AWS.JOBS_QUEUE_URL');
        return {
            consumers: [
                {
                    name: 'JobsInbound',
                    region,
                    queueUrl,
                },
                {
                    name: 'JobsInboundAlt',
                    region,
                    queueUrl,
                },
            ],
        };
    },
    inject: [ConfigService],
}),

You can then decorate different classes as consumers for JobsInbound and JobsInboundAlt, and they'll both connect and consume from the same queue.