Coder Social home page Coder Social logo

Comments (4)

chilts avatar chilts commented on August 19, 2024

Hi @hanwencheng,

Yes, the id will not change.

However, the ordering of the messages is not by id but by it's visibility (the 'visible' field). When a message is retrieved this field is updated to be now plus it's visibility window.

However, it does mean that if a message goes back on the stack, it will be visible immediately, but this doesn't mean it'll be next in the list, but it'll be somewhere near the start.

Your code should never depend on delivery of any particular message in any particular order. Even though there are some rules to this, it's better if your code stays independent of it and just takes each message as it comes. :) I'm sure you're doing this already, but am just clarifying.

Thanks for your question.

Andy

from mongodb-queue.

chilts avatar chilts commented on August 19, 2024

Oh wait, I mis-read my code! Silly me.

Yes, it is ordered by _id. :)

from mongodb-queue.

hanwencheng avatar hanwencheng commented on August 19, 2024

Thanks, Andy

Thanks for the clarification, that is a important point for me because the message processing progress need to be order by their receiving time, then everything will be fine.

Hanwen

from mongodb-queue.

chilts avatar chilts commented on August 19, 2024

Yes, but you shouldn't actually rely on that. If you need to rely on the ordering then you might need to look for another solution.

For example, if you have three messages and you process multiple messages at a time, then you may well fail with message number 1, then process 2 and 3 before 1 timesout and gets put back on the queue.

Anyway, just so you know. :)

from mongodb-queue.

Related Issues (18)

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.