We are a Hybrid cloud file server company and recently we had a requirement where we had to allow users to View a file with Google docs and upon saving the file in Google docs we need to download the file back and create a version in Cloud file server. Upon saving the file in google docs we insert a message in rabbitMQ from app nodes and then a background GoogleDocs consumer process pulls the file and create a version using REST api of the cloud file server.
As there are many components involved here there can be multiple failure scenarios from Google throttling us, to appservers going down for maintenance, to app servers throttling the background jobs if they are under heavy load. The problem with rabbitMQ is that once a message is delivered to the consumer even if the consumer doesn't acknowledges it, RabbitMQ won't redeliver the unacked message to consumers until the channel is properly closed and reopened. I tried checking rabbit transactions api to rollback the transaction in case of external component failure and also tryied basic_recover but it has its own issues and none of them worked.
So the best idea I came up was to start a timer thread in python that wakes up every 1 minute and polls Rabbitmq for pending messages and processes them and closes the channel/connection and goes back to sleep for 1 minute again. This way all unacked messages would be redelivered.
As there are many components involved here there can be multiple failure scenarios from Google throttling us, to appservers going down for maintenance, to app servers throttling the background jobs if they are under heavy load. The problem with rabbitMQ is that once a message is delivered to the consumer even if the consumer doesn't acknowledges it, RabbitMQ won't redeliver the unacked message to consumers until the channel is properly closed and reopened. I tried checking rabbit transactions api to rollback the transaction in case of external component failure and also tryied basic_recover but it has its own issues and none of them worked.
So the best idea I came up was to start a timer thread in python that wakes up every 1 minute and polls Rabbitmq for pending messages and processes them and closes the channel/connection and goes back to sleep for 1 minute again. This way all unacked messages would be redelivered.
That can be useful, I bet you have to do extra job in terms of upgrading your program.
ReplyDeleteYes I think recently rabbitmq released basic_reject api but we havent upgraded to that version, upgrading to that probably will solve this.
ReplyDeleteErm... There is a command named basic_reject which rejects a message; then rabbit tries to redeliver it... Are you sure you're using the right library?
ReplyDelete