Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Latest commit 147cf32 Jun 3, 2019 History
also hack to remove stale pid file
0 contributors

Users who have contributed to this file

31 lines (20 sloc) 852 Bytes
class Course < ActiveRecord::Base
has_and_belongs_to_many :users
def publish_to_rabbit(action)
# Message payload
msg = {:course => self, :action => action}
# TODO: connection should be pooled and created on app start?
rabbit_connection = Bunny.new(ENV['RABBITMQ_URI'] || 'amqp://localhost')
rabbit_connection.start
channel = rabbit_connection.create_channel
# Create the queue if it does not exist
channel.queue("sis.course", :exclusive => false)
# TODO: allow user to specify exchange in config
exchange = channel.default_exchange
# Publish that something about UID changed
# This should cover both course enrollments and general data about them.
exchange.publish(msg.to_json, :routing_key => 'sis.course')
logger.info('Published message: ' + msg.to_json)
rabbit_connection.close
end
end