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

252
Visualizações
Unable to execute fs.writeFile as I tried to write my protobuf message to text file

Currently I am working on an application that consumes a message from the RabbitMq broker, after consumption of the message my application should write the content into a text file for future usage.

Below are my code snippets :

const fs = require ('fs');
const config = require('../config.json');
var amqp = require('amqplib/callback_api');

amqp.connect('amqp://localhost' , function(error1 , connection){
 if(error1){
     throw error1;
}
connection.createChannel(function(error2 , channel){
 if(error2){
     throw error2;
}
channel.assertQueue(config.mode.queue,{
     durable : false
});
channel.consume(config.mode.queue, function(msg){
     let hours = new Date().getHours().toString();
     let mins = new Date().getMinutes().toString();
     
          if (mins.length != 2){
          mins = "0" + mins
          console.log(mins)
    }
     let timestamp = hours + mins
     
     fs.writeFile(`./DataStorage/${timestamp}.txt` , msg.content.toString() , err => {
        if(err){
            console.log(err)
            return;
        }
    })
        },{
            noAck: true
        })

  })
  })

I am facing issues of writing the protobuf message into a txt file, could anyone provide some kind of guidance on how I could work around this issue.

about 4 years ago · Juan Pablo Isaza
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