Class: MessageDriver::Adapters::StompAdapter
- Defined in:
- lib/message_driver/adapters/stomp_adapter.rb
Defined Under Namespace
Classes: Destination, Message, StompContext
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#poll_timeout ⇒ Object
readonly
Returns the value of attribute poll_timeout.
Attributes inherited from Base
Instance Method Summary collapse
- #build_context ⇒ Object
-
#initialize(broker, config) ⇒ StompAdapter
constructor
A new instance of StompAdapter.
- #stop ⇒ Object
- #with_connection ⇒ Object
Methods inherited from Base
#contexts, #new_context, #reset_after_tests
Constructor Details
#initialize(broker, config) ⇒ StompAdapter
Returns a new instance of StompAdapter.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/message_driver/adapters/stomp_adapter.rb', line 31 def initialize(broker, config) validate_stomp_version @broker = broker @config = config.symbolize_keys connect_headers = @config[:connect_headers] ||= {} connect_headers.symbolize_keys connect_headers[:"accept-version"] = '1.1,1.2' vhost = @config.delete(:vhost) connect_headers[:host] = vhost if vhost @poll_timeout = 1 end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
29 30 31 |
# File 'lib/message_driver/adapters/stomp_adapter.rb', line 29 def config @config end |
#poll_timeout ⇒ Object (readonly)
Returns the value of attribute poll_timeout.
29 30 31 |
# File 'lib/message_driver/adapters/stomp_adapter.rb', line 29 def poll_timeout @poll_timeout end |
Instance Method Details
#build_context ⇒ Object
90 91 92 |
# File 'lib/message_driver/adapters/stomp_adapter.rb', line 90 def build_context StompContext.new(self) end |
#stop ⇒ Object
101 102 103 104 |
# File 'lib/message_driver/adapters/stomp_adapter.rb', line 101 def stop super @connection.disconnect if @connection end |
#with_connection ⇒ Object
94 95 96 97 98 99 |
# File 'lib/message_driver/adapters/stomp_adapter.rb', line 94 def with_connection @connection ||= open_connection yield @connection rescue SystemCallError, IOError => e raise MessageDriver::ConnectionError.new(e) end |