Search code examples
resthttparchitectureatom-feedevent-driven

How to implement competing consumer using http


I really enjoyed the "Microservices: Java, The Unix Way" presentation by James Lewis.

In this presentation, James' talks about implementing a user registration service by writing a queue processing engine that reads events off an atom feed and exposes an endpoint that multiple consumers can read from to process and turn into user entities.

The notes on the specific slide (around 18:40 in the video) say that this was implemented using the competing consumer EIP:

"Queue Processing Engine implemented the competing consumer pattern using conditional GET, PUT and Etags against the atom collection exposed by the event queue"

This kind of queue (and the way they talk about having heterogeneous consumers) suggests that it is a publish-subscribe channel.

I don't really understand how this can be implemented, the EIP book says that competing consumers only works:

[...] with Point-to-Point Channels; multiple consumers on a Publish-Subscribe Channel just create more copies of each message

I assume the queue processor exposes a REST resource that the competing consumers call making GET requests for new items, but where do the the PUT requests and etags come into it?


Solution

  • A colleague spoke to Martin Fowler and James Lewis and to summarise a half remembered summary, they implied that you just don't have multiple consumers of the queue.

    Just have one consuming service and have monitoring in place to ensure that you are alerted if it goes down.