Created
February 1, 2013 02:34
-
-
Save rurounijones/4688731 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NodeStatusProcessor < TorqueBox::Messaging::MessageProcessor | |
def on_message(message) | |
status_record = DocumentQueue.where(:name => message[:queue_name]).first. | |
document_queue_processors.where(:node_name => message[:node_name]).first | |
if status_record | |
# For some reason this isn't triggering automatically so we will do it manually. | |
status_record.updated_at = Time.zone.now | |
else | |
status_record = queue.document_queue_processors.new | |
end | |
set_fields(status_record, message) | |
status_record.save | |
end | |
def set_fields(status_record, message) | |
status_record.node_name = message[:node_name] | |
status_record.consumer_count = message[:consumer_count] | |
status_record.scheduled_message_count = message[:scheduled_message_count] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment