Created
May 5, 2011 03:04
-
-
Save DylanLacey/956471 to your computer and use it in GitHub Desktop.
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
def submit | |
@job = Job.find(params[:id], :include => [:pickup_addresses, :setdown_addresses]) | |
@publish_success = false | |
AMQP.connect(:host => "localhost") do |connection| | |
logger.debug ("#{DateTime.now} | DISPATCH | Dispatching submission for Job #{@job.id}") | |
channel = AMQP::Channel.new(connection) | |
exchange = channel.direct("dispatch") | |
@publish_success = exchange.publish ActiveSupport::JSON.encode(@job, :include => [:pickup_addresses, :setdown_addresses]), :routing_key => "#{@job.city}" | |
puts "Success: #{@publish_success}" | |
end | |
respond_to do |format| | |
if @publish_success | |
format.html{redirect_to(@job, :notice => 'Job submitted to Raywood.')} | |
else | |
format.html(redirect_to(@job, :notice => "Failed to submit'")) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment