Class: ActiveMessaging::Subscription

Inherits:
Object
  • Object
show all
Defined in:
lib/activemessaging/gateway.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#destinationObject

Returns the value of attribute destination.



387
388
389
# File 'lib/activemessaging/gateway.rb', line 387

def destination
  @destination
end

#processor_classObject

Returns the value of attribute processor_class.



387
388
389
# File 'lib/activemessaging/gateway.rb', line 387

def processor_class
  @processor_class
end

#subscribe_headersObject

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

#subscribeObject



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

#unsubscribeObject



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