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

254
Views
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
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!