Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to ensure message idempotency with multiple competing consumers?
    primarykey
    data
    text
    <p>I have multiple distributed competing consumers each pulling messages off the same (transactional) queue. I want to implement each consumer as an <a href="http://www.enterpriseintegrationpatterns.com/IdempotentReceiver.html" rel="nofollow noreferrer">Idempotent Receiver</a> so I never process the same message more than once (across all consumers) even if a duplicate arrives. How can I accomplish this with multiple consumers?</p> <p>My first thought is to somehow generate a consecutive sequence number for each message before putting them on the queue and then use a shared database table to coordinate the work between consumers. I.e. consumer#1 processes msg#1 and then writes a row to DB table saying 'msg#1 is processed' (want it in a database to ensure durability). When a consumer is ready to process a message, it peeks at the next one available in the queue, consults the shared DB table and determines if this is the next msg in order. If so, it pulls it off the queue. If not, it ignores it.</p> <p>In this way, I only need to store the last message processed (as there is a consecutive sequence number for all msgs), I don't need to use a buffer storing IDs of all messages received with a negotiated 'window' size, and the messages are always processed serially (which is what I want for this scenario). </p> <p>Just curious if there is a better way? I'm concerned about the cost of querying the database whenever I need to process a message. </p> <p>If the answer is "it depends on the framework", then I had MSMQ in mind</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload