Class: JobQueue::StompAdapter
- Inherits:
-
Object
- Object
- JobQueue::StompAdapter
- Defined in:
- lib/job_queue/adapters/stomp_adapter.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ StompAdapter
constructor
A new instance of StompAdapter.
- #put(string) ⇒ Object
- #subscribe(error_report, &block) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ StompAdapter
Returns a new instance of StompAdapter.
4 5 6 7 8 9 10 |
# File 'lib/job_queue/adapters/stomp_adapter.rb', line 4 def initialize( = {}) username = [:username] password = [:password] host = [:host] || 'localhost' port = [:port] || 61613 @conn = Stomp::Connection.new(username, password, host, port, true) end |
Instance Method Details
#put(string) ⇒ Object
12 13 14 |
# File 'lib/job_queue/adapters/stomp_adapter.rb', line 12 def put(string) @conn.send("/queue/job_queue", string, :persistent => true) end |
#subscribe(error_report, &block) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/job_queue/adapters/stomp_adapter.rb', line 16 def subscribe(error_report, &block) @conn.subscribe("/queue/job_queue") loop do begin job = @conn.receive JobQueue.logger.info "Stomp received #{job}" yield job.body rescue => e error_report.call(job, e) end end end |