Giter Site home page Giter Site logo

Comments (6)

robinjmurphy avatar robinjmurphy commented on May 26, 2024

Hi @fr-kshibata are you able to share the code you're using to consume the messages?

from sqs-consumer.

kenichi-shibata avatar kenichi-shibata commented on May 26, 2024
var app = Consumer.create({
queueUrl: sqs.url,
handleMessage: function (message, done) {
var poster = formatString(message);
console.log(poster);
poster = JSON.parse(poster).Body;

client.post('/sqs/', poster, function (err, req, res, obj) {

if(err)
callback(err,null);
else {
console.log(obj);
}
});

done();
},

sqs: new AWS.SQS()
});
app.on('error', function (err) {
callback(err.message, null);
});

app.start();

from sqs-consumer.

kenichi-shibata avatar kenichi-shibata commented on May 26, 2024

I think the problem is sqs consumer sends an error if there is no more sqs message that can be received, but since this code is called by the restify.createJsonClient, then it still works even though there is no more message to be received

from sqs-consumer.

robinjmurphy avatar robinjmurphy commented on May 26, 2024

Can you show me where the callback variable comes from in that code?

Is that entire block running inside a function?

You really only want to have one consumer in your application. The error event shouldn't be connected to a particular callback, otherwise you risk that callback being called twice.

The client doesn't send an error if there are no more messages on the queue. It just sits and keeps polling.

from sqs-consumer.

kenichi-shibata avatar kenichi-shibata commented on May 26, 2024
var client = restify.createJsonClient({
    url: 'http://localhost:8080'
});

console.log(client.url.href);


sqsFunction(client, aws, sqs, function (err,req,res,obj) {
    if (err)
        console.log(err.message);

});

from sqs-consumer.

kenichi-shibata avatar kenichi-shibata commented on May 26, 2024

I removed the if(err) callback(err,null) and looks like its ok now

thanks @robinjmurphy

from sqs-consumer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.