Have been debugging for a number of hours and am out of ideas. I am not sure if this is a bug or if something is being missed, but if it's the latter hopefully writing it out here will help.
Running into an unexpected Producer does not exist error when attempting to put a message onto an SQS queue.
With some parts omitted, here is the producer in question
import { QueueNames } from "../common/sqs/types.js";
import { Injectable } from "@nestjs/common";
import { SqsService } from "@ssut/nestjs-sqs";
import { v4 } from "uuid";
//...
@Injectable()
export class ClassThatSendsToSQS {
// ...
processMessage: MessageHandler = async (params: MessageParams) => {
const value = {...};
try {
await this.sqsService.send(QueueNames.MyQueue, {
id: v4(),
body: value,
});
} catch (error) {
this.logger.warn(
`Couldn't send message to SQS queue`,
);
this.logger.error(error);
return;
}
};
}
and here is the module where nestjs-sqs is configured:
import { QueueNames } from "./types.js";
import { Module } from "@nestjs/common";
import { SqsModule } from "@ssut/nestjs-sqs";
import config from "config";
const awsSqsPrefix = config.get<string>("aws.sqs.prefix");
const prefix = `${awsSqsPrefix}`;
const region = "us-west-2";
@Module({
imports: [
// ...
SqsModule.registerAsync({
useFactory: () => {
return {
consumers: [
{
name: QueueNames.MyQueue,
queueUrl: `${prefix}-my-queue`,
region,
},
],
producers: [
{
name: QueueNames.MyQueue,
queueUrl: `${prefix}-my-queue`,
region,
},
],
};
},
}),
],
controllers: [],
providers: [
MyQueueProcessor,
],
exports: [
MyQueueProcessor,
],
})
export class SqsQueuesModule {}
This SqsQueuesModule is part of the imports: [] array within the base module for a Nest app.
Note that this same app both produces to and consumes from the queue, hence having a config object for both.
The only slightly odd part of our setup is that we have a separate SqsModule.registerAsync call within a different Nest app that does not include this producer. I wouldn't think that should have any effect on the SqsModule within this separate app though.
Is something off here with my configuration? I've looked over it a silly number of times at this point but haven't seen anything out of the ordinary
Thanks for your help
Have been debugging for a number of hours and am out of ideas. I am not sure if this is a bug or if something is being missed, but if it's the latter hopefully writing it out here will help.
Running into an unexpected
Producer does not existerror when attempting to put a message onto an SQS queue.With some parts omitted, here is the producer in question
and here is the module where
nestjs-sqsis configured:This
SqsQueuesModuleis part of theimports: []array within the base module for a Nest app.Note that this same app both produces to and consumes from the queue, hence having a config object for both.
The only slightly odd part of our setup is that we have a separate
SqsModule.registerAsynccall within a different Nest app that does not include this producer. I wouldn't think that should have any effect on theSqsModulewithin this separate app though.Is something off here with my configuration? I've looked over it a silly number of times at this point but haven't seen anything out of the ordinary
Thanks for your help