A progressive Node.js framework for building efficient and scalable server-side applications, heavily inspired by Angular.
/!\ Not yet published /!\
$ npm i --save nestjs-aws-sqs
To consume data for a specific queue, you need to register it using the SQSModule
, and provide a consumer class.
The consumer class is basically a class implementing the SQSMessageHandler interface, and decorated with @SQSConsumer
. The @SQSConsumer
annotation simply takes the name of the queue to consume.
For example:
// imports...
@SQSConsumer('test')
export class TestConsumer implements SQSMessageHandler {
handleMessage(message: SQS.Message): void {
console.log(`I received a message : ${message.Body}`);
}
}
@Module({
imports: [
SQSModule.register([
{ name: 'test' }
])
],
providers: [TestConsumer]
})
export class AppModule {}
The consumer can provide an async handleMessage
method aswell:
@SQSConsumer('test')
export class TestConsumer implements SQSMessageHandler {
constructor (private readonly myAwesomeService: MyAwesomeService) {}
async handleMessage(message: SQS.Message): Promise<void> {
await this.myAwesomeService.processMessage(body);
}
}
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
- Author - Yann Kaiser
- Maintainers - Yann Kaiser
- Website - https://nestjs.com
Nest is MIT licensed.