Answer the question
In order to leave comments, you need to log in
Rabbitmq last state queue (lvc). How to implement it?
We have a service that monitors the location of vehicles (vehicles). The task is to notify another service via amqp (choose rabbit) about a change in the state of the vehicle (speed, coordinates, etc.). I would like to make sure that only the last state is stored in the queue. If the recipient for some reason did not read the previous state of the vehicle, the message will be overwritten. I found the rabbitmq-lvc-exchange plugin but I can't figure out how it works. Do I need to create a queue for each vehicle? For example, for a car with id 1234567 , the queue name will be vehicle.state.change.1234567. Somebody will prompt as still it is possible to implement the given task in rabbit? Please do not recommend using key-value stores like redis. And if you can make one queue for all vehicles, tell me how to implement it? That is, if we have 200 vehicles, then there can be a maximum of 200 messages in the queue
Answer the question
In order to leave comments, you need to log in
The plugin works with direct bindings, each vehicle will have its own queue. Maintaining a queue is not the hardest job for RabbitMQ.
If you are satisfied with the limited plugin, you can not consider the option with a DBMS. But if it is through RabbitMQ, then storing everything in one queue is not the best idea, because you will do n checks for each sneeze.
With two queues, it’s already more interesting when the first one is a buffer, and the second one is with actual information, but you need to make your own worker that reads from the buffer and writes to the queue, providing unique values. There are two queues, but the load you get will be on the worker, not the RabbitMQ cluster, and from the second queue, clients can read and search for a message with info about their vehicle.
But the feature of RabbitMQ is still in queue/exchanges, doing this on RabbitMQ is not very good.
I’ll add on the plugin, I haven’t used it myself, but from the description and code you can tell how it works.
(1) When a message is published to such an exchanger:
- The link <routing_key>=<value>
[ code ]
is saved - Further routing occurs in the same way as for the Direct exchanger [ code ]
(2) When a queue clings to such an exchanger:
- The value from the internal database is searched for by the key of the link
- The message with the latest value is published to the queue
That is, if you need to save the state for N objects through such a mechanism, then in order to receive, you will have to make N queue bindings for the exchanger each time, then remove this binding N times. And also do not forget to set a limit on the length of the queue, since no one needs real messages.
Alternatively, you can fork this exchanger and finish it so that when publishing, only the latest states are saved (without further publication as Direct), and when subscribing to the exchanger, RabbitMQ would send all states at once :-)
Why not use cache? Infinispan involves clustering and subscription to updates. Subscribe to updates in the service and you will receive updates of the latest status.
One queue, one binding.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question