Class: ActiveMessaging::Subscription
- Inherits:
-
Object
- Object
- ActiveMessaging::Subscription
- Defined in:
- lib/activemessaging/gateway.rb
Instance Attribute Summary collapse
-
#destination ⇒ Object
Returns the value of attribute destination.
-
#processor_class ⇒ Object
Returns the value of attribute processor_class.
-
#subscribe_headers ⇒ Object
Returns the value of attribute subscribe_headers.
Instance Method Summary collapse
-
#initialize(destination, processor_class, subscribe_headers = {}) ⇒ Subscription
constructor
A new instance of Subscription.
- #subscribe ⇒ Object
- #unsubscribe ⇒ Object
Constructor Details
#initialize(destination, processor_class, subscribe_headers = {}) ⇒ Subscription
Returns a new instance of Subscription.
385 386 387 388 |
# File 'lib/activemessaging/gateway.rb', line 385 def initialize(destination, processor_class, subscribe_headers = {}) @destination, @processor_class, @subscribe_headers = destination, processor_class, subscribe_headers subscribe_headers['id'] = processor_class.name.underscore unless subscribe_headers.key? 'id' end |
Instance Attribute Details
#destination ⇒ Object
Returns the value of attribute destination.
383 384 385 |
# File 'lib/activemessaging/gateway.rb', line 383 def destination @destination end |
#processor_class ⇒ Object
Returns the value of attribute processor_class.
383 384 385 |
# File 'lib/activemessaging/gateway.rb', line 383 def processor_class @processor_class end |
#subscribe_headers ⇒ Object
Returns the value of attribute subscribe_headers.
383 384 385 |
# File 'lib/activemessaging/gateway.rb', line 383 def subscribe_headers @subscribe_headers end |
Instance Method Details
#subscribe ⇒ Object
390 391 392 393 |
# File 'lib/activemessaging/gateway.rb', line 390 def subscribe ActiveMessaging.logger.error "=> Subscribing to #{destination.value} (processed by #{processor_class})" Gateway.connection(@destination.broker_name).subscribe(@destination.value, subscribe_headers) end |
#unsubscribe ⇒ Object
395 396 397 398 |
# File 'lib/activemessaging/gateway.rb', line 395 def unsubscribe ActiveMessaging.logger.error "=> Unsubscribing from #{destination.value} (processed by #{processor_class})" Gateway.connection(destination.broker_name).unsubscribe(destination.value, subscribe_headers) end |