Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

161
Visualizações
how can set result for counsme in rabitmq and nodejs

i have two service and i created that with nodejs and typescript .

i want to send and recive message between these two services with reabitMQ .

i do it with this code :

Publisher :

await MessageBroker.Publish('coin', 'transaction', {
            type: MessageBrokerType.Transfer,
            to: 'to',
            amount: amount
});

Consume :

MessageBroker.channel.consume(exchange + '.' + queue, async (msg: any) => {

    const { to, amount , type } = JSON.parse(msg.content);

    const transfer = await UnitOfWork.coinRepository.transfer(to, amount);
    console.log(to, amount);
})

it's worked and send message from publisher to consume but i have a problem .

i need to set result for consume and send it for publisher .

for exmaple maybe i have a problem in this line UnitOfWork.coinRepository.transfer(to, amount); and i should send to publisher error message and if operation sucess send message to subscriber about success result .

now how can i solve this problem and set result for message between two service ?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

What you have done so far is implementation of pub/sub with RabbitMQ and what you need to do is to setup a message-driven architecture (RPC).

This document clarifies what you need to do perfectly for an RPC pattern:

https://www.rabbitmq.com/tutorials/tutorial-six-javascript.html

The examples are written in Js but you can surely change them to Typescript.

Message-Driven will be handled by correlationId which is used to correlate RPC responses with requests, that's what you need to implement, more information can be found in the document. At the end of day if you weren't successful implementing it, ask me for a real sample with Typescript.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda