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.
389 390 391 392 |
# File 'lib/activemessaging/gateway.rb', line 389 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.
387 388 389 |
# File 'lib/activemessaging/gateway.rb', line 387 def destination @destination end |
#processor_class ⇒ Object
Returns the value of attribute processor_class.
387 388 389 |
# File 'lib/activemessaging/gateway.rb', line 387 def processor_class @processor_class end |
#subscribe_headers ⇒ Object
Returns the value of attribute subscribe_headers.
387 388 389 |
# File 'lib/activemessaging/gateway.rb', line 387 def subscribe_headers @subscribe_headers end |
Instance Method Details
#subscribe ⇒ Object
394 395 396 397 |
# File 'lib/activemessaging/gateway.rb', line 394 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
399 400 401 402 |
# File 'lib/activemessaging/gateway.rb', line 399 def unsubscribe ActiveMessaging.logger.error "=> Unsubscribing from #{destination.value} (processed by #{processor_class})" Gateway.connection(destination.broker_name).unsubscribe(destination.value, subscribe_headers) end |