module StompJob::Worker::ClassMethods

Attributes

queue_name[RW]
stomp_connection[RW]

Public Instance Methods

enqueue(*args) click to toggle source

Enqueue a payload for a worker

# File lib/stomp_job/worker.rb, line 43
def enqueue(*args)
  stomp_connection.publish(queue_name, *args)
end
listen!() click to toggle source

Make the current connection listen for messages that should be handled by this worker. Typically invoked by the Consumer.

# File lib/stomp_job/worker.rb, line 50
def listen!
  stomp_connection.subscribe(self)
end
stomp_options(opts={}) click to toggle source

stomp_options controls parameters for the worker and the queue. All supported options are:

queue_name (required) - The name of the queue to use on

the queue broker. Will be created
if it doesn't already exist.

stomp_connection - The STOMP connection to use for

the worker. An instance of
StompJob::Connection. By default,
all workers will use the same
STOMP connection.
# File lib/stomp_job/worker.rb, line 36
def stomp_options(opts={})
  opts = opts.with_indifferent_access if opts.respond_to?(:with_indifferent_access)
  @queue_name = opts[:queue_name]
  @stomp_connection = opts[:stomp_connection]
end