Reputation: 7522
I am using RabbitMQ to handle a lot of data. I have three types of consumers: downloader, extracter
and importer
. They must work sequentially in the order I mentioned above e.g. the downloader
will download a bunch of files, pass to extracter
and after extracting them the importer
should import the info from the files into DB. My question is how can I implement this kind of functionality? Is this is a good approach to put the messages into extracter
's queue from downloader
(consumer
)? Or there is another solution to this?
Upvotes: 1
Views: 805
Reputation: 112875
This seems like a great case to use three separate queues. You'd have a download
queue, an extraction
queue, and an import
queue.
The consumer of each queue would be responsible for putting a message on the next queue in the pipeline after it has finished its work.
So the workflow would look like this (queues prefixed with queue.
to make them obvious):
??? -> queue.download
queue.download -> downloader -> download complete -> queue.extraction
queue.extraction -> extracter -> extraction complete -> queue.import
queue.import -> importer -> import complete -> ???
A couple of things to note:
download
queue to kick things off.compression
step (for example)? Have the downloader put messages into a compression
queue, and then once that step is complete, put a message in the extraction
queue.downloader
that pull messages off the same work queue.Hope this helps!
Upvotes: 1