We are building an AMQP messaging system in Ruby. However, we have a problem with error handling.
We keep a whitelist of exceptions that are safe, and a message in RabbitMQ can be left unrecognized and repeated by another employee. However, with unknown or unexpected errors, we assume that the same failure will always occur regardless of how many times the message is processed by the worker.
This means that when an unknown error occurs, we need to capture it, register it somewhere (currently MySQL), and then send an ACK call to RabbitMQ to remove the message from the queue.
Currently, everything is built using the amqp array, which has an EventMachine event. This causes a problem by calling the #ack method, does not mean that the ACK was sent to RabbitMQ due to the asynchronous behavior of gem.
Earlier, I circumvented this problem by roughly putting the promotion code in EM.next_tick . Now we need the multithreading of each working Ruby for performance, and next_tick does not work.
In short:
How could you run a certain piece of code synchronously right after an asynchronous ACK call in the amqp stone? A callback would have been nice, but there are no available, at least, not without serious malicious monkey fixes.
jimeh source share