* VRFS-19; wip
This commit is contained in:
parent
67087c3370
commit
a1cb141fab
|
|
@ -42,6 +42,11 @@ class ApiMusicSessionsController < ApplicationController
|
|||
@music_session_client.user = current_user
|
||||
@music_session_client.save
|
||||
|
||||
unless has_errors?
|
||||
# send out notification to queue to the rest of the session
|
||||
|
||||
end
|
||||
|
||||
respond_with @music_session_client, responder: ApiResponder, :location => api_session_participant_detail_url(@music_session_client)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -71,5 +71,7 @@ module SampleApp
|
|||
# Add the assets/fonts directory to assets.paths
|
||||
config.assets.paths << "#{Rails.root}/app/assets/fonts"
|
||||
|
||||
config.rabbitmq_host = "localhost"
|
||||
config.rabbitmq_port = 5672
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
require 'amqp'
|
||||
require 'jam_ruby'
|
||||
|
||||
# Creates a connection to RabbitMQ.
|
||||
# On that single connection, a channel is created (which is a way to multiplex multiple queues/topics over the same TCP connection with rabbitmq)
|
||||
# Then connections to the client_exchange and user_exchange are made, and put into the MQRouter static variables
|
||||
# If this code completes (which implies that Rails can start to begin with, because this is in an initializer),
|
||||
# then the Rails app itself is free to send messages over these exchanges
|
||||
# TODO: reconnect logic if rabbitmq goes down...
|
||||
|
||||
module JamWebEventMachine
|
||||
|
||||
def self.start
|
||||
|
||||
Thread.abort_on_exception = true
|
||||
|
||||
# create a new thread separate from the Rails main thread that EventMachine can run on
|
||||
Thread.new do
|
||||
|
||||
EM.run do
|
||||
AMQP.start(:host => Rails.application.config.rabbitmq_host, :port => Rails.application.config.rabbitmq_port) do |connection|
|
||||
AMQP::Channel.new do |channel, open_ok|
|
||||
Rails.logger.debug("Channel ##{channel.id} is now open!")
|
||||
|
||||
AMQP::Exchange.new(channel, :topic, "clients") do |exchange|
|
||||
Rails.logger.debug("#{exchange.name} is ready to go")
|
||||
MQRouter.client_exchange = exchange
|
||||
end
|
||||
|
||||
AMQP::Exchange.new(channel, :topic, "users") do |exchange|
|
||||
Rails.logger.debug("#{exchange.name} is ready to go")
|
||||
MQRouter.user_exchange = exchange
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
JamWebEventMachine.start
|
||||
Loading…
Reference in New Issue