I'm working with RabbitMQ and I want on the server side to conduct a calculation each time an Exchange receives a message.
I have a queue for ratings and when too many bad reviews (let's say more than ten) received, then a consumer should be notified.
What options are there for serverside logic ? I've been reading about Spring RabbitMQ, but am not sure ?
Best How To :
There isn't really a "server side" with a message-based system; rather, the RabbitMQ service sits somewhere and relays messages to and from any number of producers and consumers. Depending on the hardware you have available, and the amount of processing being performed, these could all be on the same server, or you could have resources dedicated to each task.
Calculations based on the content of messages is the job of consumers, which can be written in any language you feel comfortable writing them in, as long as you use a serialization of the message that all can understand (e.g. JSON, XML). For a simple counter, you may not need much framework to extract the data you need.
Any number of Queues can receive copies of messages from the same Exchange, so you can either pick up all messages from the exchange and count only the bad reviews, or you can put the rating into the "routing key" and use a "topic exchange" to pre-filter them.
After that, you could use a simple memory store like Redis to store a counter, and when it reaches the limit, either act on it within that consumer, or publish a message to a new exchange for processing by a different consumer.