Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

251
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda