Class: SubscriptionsConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/subscriptions-config.rb

Constant Summary collapse

DEFAULT_CONFIG =
{
  hostname: 'localhost',
  message_bus_type: 'IbmMQ',
  exchange: 'dataDelivery',
  routing_spec: "",
  queue_base: "",
  durable: false,
  model: "",
  extension: "",
  port: "1414",
  trace_level: "0",
  credentials: "",
  vhost: "",
  keep_queue: "n",
  sub_name: ""
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ SubscriptionsConfig

Returns a new instance of SubscriptionsConfig.



21
22
23
# File 'lib/subscriptions-config.rb', line 21

def initialize(config)
  @config = DEFAULT_CONFIG.merge(config)
end

Instance Method Details

#create!Object



25
26
27
28
29
# File 'lib/subscriptions-config.rb', line 25

def create!
  create_rabbitmq! if message_bus_type == 'RabbitMQ'
  create_ibmmq! if message_bus_type == 'IbmMQ'
  self
end

#delete!Object



31
32
33
34
35
# File 'lib/subscriptions-config.rb', line 31

def delete!
  delete_rabbit! if message_bus_type == 'RabbitMQ'
  delete_ibmmq! if message_bus_type == 'IbmMQ'
  self
end

#show_bindingsObject



42
43
44
45
# File 'lib/subscriptions-config.rb', line 42

def show_bindings
  puts bindings
  self
end

#show_environmentObject



47
48
49
50
51
52
# File 'lib/subscriptions-config.rb', line 47

def show_environment
  puts "Bus Type: #{message_bus_type}"
  show_environment_ibmmq if message_bus_type == 'IbmMQ'
  show_environment_rabbit if message_bus_type == 'RabbitMQ'
  self
end

#show_keep_queueObject



63
64
65
66
# File 'lib/subscriptions-config.rb', line 63

def show_keep_queue
  puts keep_queue
  self
end

#show_sub_nameObject



68
69
70
71
# File 'lib/subscriptions-config.rb', line 68

def show_sub_name
  puts sub_name
  self
end

#show_topicsObject



37
38
39
40
# File 'lib/subscriptions-config.rb', line 37

def show_topics
  puts topics
  self
end

#subscription_name(queue_name, routing_key) ⇒ Object



54
55
56
57
58
59
60
61
# File 'lib/subscriptions-config.rb', line 54

def subscription_name(queue_name, routing_key)
  if sub_name.nil?
    routing_key_digest = Digest::SHA1.hexdigest(routing_key)[0..8]
    "#{queue_name}.#{routing_key_digest}"
  else
    sub_name
  end
end