Class: TorqueBox::Messaging::Queue

Inherits:
Destination show all
Defined in:
lib/torquebox/messaging/queue.rb

Constant Summary

Constants inherited from Destination

Destination::PRIORITY_MAP

Instance Attribute Summary

Attributes inherited from Destination

#connect_options, #connection_factory, #enumerable_options, #name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Destination

#_dump, _load, #each, #initialize, #normalize_options, #publish, #receive, #wait_for_destination, #with_session

Constructor Details

This class inherits a constructor from TorqueBox::Messaging::Destination

Class Method Details

.start(name, options = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/torquebox/messaging/queue.rb', line 25

def self.start( name, options={} )
  selector = options.fetch( :selector, "" )
  durable  = options.fetch( :durable,  true )
  jndi     = options.fetch( :jndi,     [].to_java(:string) )
  TorqueBox::ServiceRegistry.lookup("jboss.messaging.default.jms.manager") do |server|
    server.createQueue( false, name, selector, durable, jndi )
  end
  new( name )
end

Instance Method Details

#publish_and_receive(message, options = {}) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/torquebox/messaging/queue.rb', line 41

def publish_and_receive(message, options={})
  result = nil
  with_session do |session|
    result = session.publish_and_receive(self, message,
                                         normalize_options(options))
  end
  result
end

#receive_and_publish(options = {}, &block) ⇒ Object



50
51
52
53
54
# File 'lib/torquebox/messaging/queue.rb', line 50

def receive_and_publish(options={}, &block)
  with_session do |session|
    session.receive_and_publish(self, normalize_options(options), &block)
  end
end

#stopObject



35
36
37
38
39
# File 'lib/torquebox/messaging/queue.rb', line 35

def stop
  TorqueBox::ServiceRegistry.lookup("jboss.messaging.default.jms.manager") do |server|
    server.destroyQueue( name )
  end
end

#to_sObject



56
57
58
# File 'lib/torquebox/messaging/queue.rb', line 56

def to_s
  "[Queue: #{super}]"
end