Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

202
Views
quiero usar el emisor nestjs de main.ts. tengo una función en la clase de controlador que tiene @OnEvent('send>email'). por favor guíame como puedo invocar el evento
  1. Hola, soy nuevo en nodejs por favor guíame. esta es la clase main.ts que tiene una declaración para invocar OnEvent('send_email') en la clase de controlador, también puede ver la clase de controlador.
  2. lo agregué
 async function bootstrap() { const myEmitter = new EventEmitter2(); const app = await NestFactory.createMicroservice( AppModule, appConfig.microservice, ); //#region RabbitMQ Implementation const email = { email: { from: 'GeoNoon <xzy@yahoo.com>', to: 'ali.whu@yahoo.com', subject: 'Hello ✔', html: '<b>Hello world? 测试邮件</b>', }, }; amqplib.connect( 'amqp://localhost', (error0, connection) => { if (error0) { throw error0; } connection.createChannel((error1, channel) => { if (error1) { throw error1; } const queue = 'Test_emails_queue'; channel.assertQueue(queue, { durable: false }); channel.sendToQueue(queue, Buffer.from(JSON.stringify(email))); console.log(' [*] Waiting for message', queue); // myEmitter.on('send_email', function(email:{}) { // console.log(this.event, email); // }); const response = myEmitter.emit('send_email', JSON.stringify(email)); console.log(response); }); }, ); //#endregion await app.listen(); console.log('Geonoon Mail Microservice is listening'); } bootstrap();
  1. esta es la clase app.controller que tiene un método para enviar un correo electrónico al cliente.
  2. por favor ayúdame como puedo hacer esto. Gracias
 export class AppController { constructor(private readonly appService: AppService) {} @OnEvent('send_email') async handlerEmailSend(data: Record<string, any>) { console.log(data); if ( data.email && data.email.from && data.email.to && data.email.subject && (data.email.html || data.email.text) ) { return await this.appService.sendEmail(data as EmailContent); } else { Logger.warn('电子邮件数据格式错误'); } } }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!