Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AcknowledgementWorker
- include Sneakers::Worker
- from_queue "currencies.acknowledgements"
- def work(message)
- consumer_id = message[:id]
- currency = Currency.find_by(uuid: message[:uuid])
- if currency
- currency.update_attribute("consumer_#{consumer_id}", true)
- ack!
- else
- requeue_or_reject
- end
- end
- private
- def requeue_or_reject
- if !@countdown
- @countdown = 5
- elsif @countdown > 0
- @countdown =- 1
- requeue!
- else
- reject!
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement