We have rabbitmq consumer where we get image urls from where we:
- download the image through this url.
- resize the image to our standard aspect ratio
- upload on our server at the path specified by the client.
The input to this consumer is:
{
"imageUrl": "xyz.jpg", //url of the existing image
"path": "/stock/123", //server path where we need to store this image,
"team": "teamA" //team that sends this image.
}
The consumer first downloads the images, upload this to the server at given path. Post this, we need to store this image in our database to indicate its ready to be used i.e. in this case, we will save it in mysql through "teamA-stored-procedure".
We have teams from "teamA" to "teamZ" and every team has different database table where they dump the image information i.e. its host-url, its path etc.
We have put lots of if-elseif checks in the consumer i.e. if "module" is "teamA", we will hit "teamA-StoredProcedure"...similarly for teamB-teamZ.
To remove these checks, we can:
- Instead of calling respective team's stored procedure in the consumer, we can expose APIs for each team and the API URL can be passed as input to the consumer. Once, image download/resize/upload is done, it hits the respective team's API.
- Create a Topic based exchange and host separate consumer for each team. Each consumer would listen to respective team's messages only. This looks like a perfect use case for "topic based exchange" but there is the overhead of hosting multiple consumers instead of one.
Is it perfect use case for using "Topic based Exchange" OR using "Direct exchange" with single consumer and delegating rest to respective API is fine?