Skip to content

Instantly share code, notes, and snippets.

@DylanLacey
Created May 5, 2011 03:04
Show Gist options
  • Save DylanLacey/956471 to your computer and use it in GitHub Desktop.
Save DylanLacey/956471 to your computer and use it in GitHub Desktop.
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