Created
August 17, 2011 22:02
-
-
Save anewusername1/1152758 to your computer and use it in GitHub Desktop.
subscriber code example
This file contains hidden or 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
EM.schedule do | |
user_subscription = Subscriptions::User.new | |
Ragnar.exchange(:topic, 'events') do |x| | |
x.queue_prefix = :service_name | |
x.subscribe('user.delete', &user_subscription.method(:user_delete)) | |
x.subscribe('user.login', &user_subscription.method(:user_login)) | |
end | |
end | |
module Subscriptions | |
class User | |
def user_delete(headers, payload) | |
begin | |
# do something here | |
rescue | |
# handle the errors | |
end | |
end | |
def user_login(headers, payload) | |
begin | |
# do something here | |
rescue | |
#handle the errors | |
end | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment