Permalink
Browse files

Temporarily adding the listener back into the code so we can replicat…

…e the messenger infinite loop issue on preview.

This reverts commit 2616944.
  • Loading branch information...
1 parent 2616944 commit 49c20f7c7eed131b89fcba9e5c7aa939472489c2 @JordanHatch JordanHatch committed Jan 12, 2012
Showing with 43 additions and 1 deletion.
  1. +36 −0 lib/publication_listener.rb
  2. +7 −1 lib/tasks/messenger.rake
@@ -0,0 +1,36 @@
+class PublicationListener
+ def listen
+ Signal.trap('TERM') do
+ client.close
+ exit
+ end
+
+ marples = Messenger.instance.client
+
+ marples.when 'publisher', '*', 'updated' do |publication|
+ logger.info "Found publication #{publication}"
+
+ begin
+ logger.info "Processing artefact #{publication['panopticon_id']}"
+ logger.info "Publication #{publication['_id']}"
+
+ artefact = Artefact.find(publication['panopticon_id'])
+ artefact.update_attribute :publication_id, publication['_id']
+
+ logger.info 'Artefact saved'
+ rescue => e
+ logger.error "Unable to process message #{publication}"
+ logger.error [e.message, e.backtrace].flatten.join("\n")
+ end
+
+ logger.info "Finished processing message #{publication}"
+ end
+
+ logger.info 'Listening for updated objects in Publisher'
+ marples.join
+ end
+
+ def logger
+ @logger ||= Rails.logger
+ end
+end
View
@@ -6,7 +6,13 @@ namespace :messenger do
Rake::Task["environment"].invoke
DeletedPublicationListener.new.listen
end
-
+
+ Daemonette.run("panopticon_publication_listener") do
+ require "publication_listener.rb"
+ Rake::Task["environment"].invoke
+ PublicationListener.new.listen
+ end
+
Daemonette.run('panopticon_contact_listener') do
require 'contact_listener.rb'
Rake::Task['environment'].invoke

0 comments on commit 49c20f7

Please sign in to comment.