Make Activemessaging Working on Rails 2.1.0
Few days ago we had updated the application on which project currently I am working to make it compatible with rails 2.1.0. Previously we were using rails 1.2.5. In our application we have mail sending module for which we are using activemessaging plugin. It was working fine on previous version. But, unfortunately on new version it was not working. We thought that we made some mistake while updating to the new version. The problem was the poller was not starting and it was showing the following message when we were trying to run the poller-
Dispatch exception: undefined method `prepare_application' for #Dispatcher:0xb6d9ffec>
/mnt/app/releases/20081017130017/vendor/plugins/activemessaging/lib/activemessaging/support.rb:8:in `prepare_application_for_dispatch'
/mnt/app/releases/20081017130017/vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:189:in `prepare_application'
/mnt/app/releases/20081017130017/vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:199:in `dispatch'
/mnt/app/releases/20081017130017/vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:197:in `synchronize'
/mnt/app/releases/20081017130017/vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:197:in `dispatch'
/mnt/app/releases/20081017130017/vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:93:in `stop'
/mnt/app/releases/20081017130017/vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:90:in `start'
/mnt/app/releases/20081017130017/vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:90:in `stop'
/mnt/app/releases/20081017130017/vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:80:in `each'
/mnt/app/releases/20081017130017/vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:80:in `stop'
/mnt/app/releases/20081017130017/vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:67:in `start'
/mnt/app/releases/20081017130017/vendor/plugins/activemessaging/lib/activemessaging.rb:108:in `start'
/mnt/app/releases/20081017130017/vendor/plugins/activemessaging/poller.rb:14
/var/lib/gems/1.8/gems/daemons-1.0.10/lib/daemons/application.rb:176:in `load'
/var/lib/gems/1.8/gems/daemons-1.0.10/lib/daemons/application.rb:176:in `start_load'
/var/lib/gems/1.8/gems/daemons-1.0.10/lib/daemons/application.rb:253:in `start'
/var/lib/gems/1.8/gems/daemons-1.0.10/lib/daemons/controller.rb:72:in `run'
/var/lib/gems/1.8/gems/daemons-1.0.10/lib/daemons.rb:139:in `run'
/var/lib/gems/1.8/gems/daemons-1.0.10/lib/daemons/cmdline.rb:105:in `call'
/var/lib/gems/1.8/gems/daemons-1.0.10/lib/daemons/cmdline.rb:105:in `catch_exceptions'
/var/lib/gems/1.8/gems/daemons-1.0.10/lib/daemons.rb:138:in `run'
script/poller:21
After googling I found that the plugin has a problem to work with rails 2.1.0. http://groups.google.com/group/activemessaging-discuss/browse_thread/thread/41989b6599146ba4- - in this site you will find the details. After replacing the content of vendor/activemessaginglib/activemessaging/support.rb with the following code the poller was working fine -
require 'dispatcher' unless defined?(::Dispatcher)
::Dispatcher.class_eval do
def self.prepare_application_for_dispatch
new(STDOUT).reload_application
end
def self.reset_application_after_dispatch
new(STDOUT).cleanup_application
end
end
It is really bad if someone needs to do such things to make the plugins working while updating any project to any newer rails version.
1 comment:
Let me add something here; the current version of active messaging works for 2.1 (yes, there are a few open defects, such as you link to, but not causing the exception you report here).
The error you have posted is going to happen if you updated to rails 2.x w/o updating the active messaging plugin as well.
Lots of plugins need to be updated when you update to a major new version of rails; that is hardly unique to active messaging, and I don't think you would call them all "really bad": the comatose, acts_as_versioned and will_paginate plugins come to mind as other plugins that had to be upgraded when we moved to 2.x.
If you want to understand why there is a dependency on the Rails Dispatcher class in Active Messaging (which led to this incompatibility when Rails completely changed the Dispatcher between versions) I would be happy to discuss that, and give you my reasons for relying on and reusing this code from Rails (it has also been discussed on the list I believe, as I recall).
-Andrew Kuklewicz
Post a Comment