Class: StompJob::Connection
- Inherits:
-
Object
- Object
- StompJob::Connection
- Defined in:
- lib/stomp_job/connection.rb
Class Method Summary collapse
- .default_connection ⇒ Object
- .from(stomp_configuration = {}) ⇒ Object
- .refresh_default_connection ⇒ Object
Instance Method Summary collapse
-
#publish(queue_name, *args) ⇒ Object
Using a marshaller allows us to send complex messages over stomp.
- #subscribe(worker_klass) ⇒ Object
Class Method Details
.default_connection ⇒ Object
10 11 12 |
# File 'lib/stomp_job/connection.rb', line 10 def self.default_connection @default_connection ||= refresh_default_connection end |
.from(stomp_configuration = {}) ⇒ Object
6 7 8 |
# File 'lib/stomp_job/connection.rb', line 6 def self.from(stomp_configuration={}) new(new_client( Configuration.configuration.merge(stomp_configuration) )) end |
.refresh_default_connection ⇒ Object
14 15 16 |
# File 'lib/stomp_job/connection.rb', line 14 def self.refresh_default_connection @default_connection = new end |
Instance Method Details
#publish(queue_name, *args) ⇒ Object
Using a marshaller allows us to send complex messages over stomp.
Using Ruby's built-in Marshal by default.
22 23 24 |
# File 'lib/stomp_job/connection.rb', line 22 def publish(queue_name, *args) @connection.publish(safe_queue_name(queue_name), marshaller.dump(args)) end |
#subscribe(worker_klass) ⇒ Object
26 27 28 29 30 |
# File 'lib/stomp_job/connection.rb', line 26 def subscribe(worker_klass) @connection.subscribe( safe_queue_name(worker_klass.queue_name) ) do |msg| worker_klass.new.perform( *marshaller.load(msg.body) ) end end |