Guest User

Untitled

a guest
Jul 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. require "rubygems"
  2. require "bunny"
  3. require "json"
  4.  
  5. # Returns a connection instance
  6. conn = Bunny.new ENV['CLOUDAMQP_URL']
  7. # The connection will be established when start is called
  8. conn.start
  9.  
  10. # Create a channel in the TCP connection
  11. ch = conn.create_channel
  12. # Declare a queue with a given name, examplequeue. In this example is a durable shared queue used.
  13. q = ch.queue("examplequeue", :durable => true)
  14.  
  15. # Method for the PDF processing
  16. def pdf_processing(json_information_message)
  17. puts "Handling pdf processing for:"
  18. puts json_information_message['email']
  19. sleep 5.0
  20. puts "pdf processing done"
  21. end
  22.  
  23. # Set up the consumer to subscribe from the queue
  24. q.subscribe(:block => true) do |delivery_info, properties, payload|
  25. json_information_message = JSON.parse(payload)
  26. pdf_processing(json_information_message)
  27. end
Add Comment
Please, Sign In to add comment