Class: MessageDriver::Adapters::StompAdapter::StompContext
- Inherits:
-
ContextBase
- Object
- ContextBase
- MessageDriver::Adapters::StompAdapter::StompContext
- Extended by:
- Forwardable
- Defined in:
- lib/message_driver/adapters/stomp_adapter.rb
Instance Attribute Summary
Attributes inherited from ContextBase
Instance Method Summary collapse
-
#handle_create_destination(name, dest_options = {}, message_props = {}) ⇒ Object
def handle_subscribe(destination, consumer) destination.subscribe(&consumer) end.
- #handle_pop_message(destination, options = {}) ⇒ Object
- #handle_publish(destination, body, headers = {}, _properties = {}) ⇒ Object
Methods inherited from ContextBase
#ack_message, #begin_transaction, #commit_transaction, #consumer_count, #create_destination, #handle_ack_message, #handle_begin_transaction, #handle_commit_transaction, #handle_consumer_count, #handle_message_count, #handle_nack_message, #handle_rollback_transaction, #handle_subscribe, #in_transaction?, #initialize, #invalidate, #message_count, #nack_message, #pop_message, #publish, #rollback_transaction, #subscribe, #supports_client_acks?, #supports_subscriptions?, #supports_transactions?, #valid?
Constructor Details
This class inherits a constructor from MessageDriver::Adapters::ContextBase
Instance Method Details
#handle_create_destination(name, dest_options = {}, message_props = {}) ⇒ Object
def handle_subscribe(destination, consumer) destination.subscribe(&consumer) end
55 56 57 |
# File 'lib/message_driver/adapters/stomp_adapter.rb', line 55 def handle_create_destination(name, = {}, = {}) Destination.new(adapter, name, , ) end |
#handle_pop_message(destination, options = {}) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/message_driver/adapters/stomp_adapter.rb', line 65 def (destination, = {}) with_connection do |connection| sub_id = connection.uuid msg = nil count = 0 connection.subscribe(destination.queue_path, , sub_id) while msg.nil? && count < max_poll_count msg = connection.poll if msg.nil? count += 1 sleep 0.1 end end connection.unsubscribe(destination.queue_path, , sub_id) Message.new(self, destination, msg) if msg end end |
#handle_publish(destination, body, headers = {}, _properties = {}) ⇒ Object
59 60 61 62 63 |
# File 'lib/message_driver/adapters/stomp_adapter.rb', line 59 def handle_publish(destination, body, headers = {}, _properties = {}) with_connection do |connection| connection.publish(destination.queue_path, body, headers) end end |