I have the following scenario:
My approach:
Questions:
An exchange send new product jobs in a "newProduct" queue to which all the consumers are consuming from.
This looks good to me.
The consumer y that reads such a message notifies to the producer service (on a separate queue) that he is now in charge of product x. This is also fine, I guess if producer did not receive notification that product X is taken care of it will need to do something. The producer then sends all messages for product x to a queue proper to consumer y.
I'd send all messages for product X with the same routing key, like product-X
. Which is what you probably mean here. I'd avoid telling producer who exactly handles the product-X now. For better separation of concerns and simplicity producers should know as less as possible about consumers and their queues and vice versa.
When a new consumer service z goes online, it notifies the producer service on a therefore specific queue that he is online such that the producer can create a binding in the exchange for z's proper queue.
You could do it this way, but I'd do it differently:
When consumer goes online, it will create needed queues (or subscribe to existing queues) by itself.
I see it like this:
product-Z
product-Z
and they end up in Consumer's queue.Make sure your consumer has some High Availability, otherwise you may end up in the situation when your consumer started to handle some of the messages and then gone dead, while producer is continuing to send messages for now unhandled product.