messaging-adapter 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1921ca8d41d072562f3ab6e308d47b2c977bbd40
4
- data.tar.gz: 8bc7c59595789439cff189d73b443f7967cceda8
3
+ metadata.gz: 5d50bf6bba3832495f12d2989f005b837a83bfc2
4
+ data.tar.gz: 99fbf914726b7fae02d6398fc639e37b1e01632b
5
5
  SHA512:
6
- metadata.gz: bb4e8a5f861fa7c2af4934ee2fc816d6bca3c695036cca5a08c56b05d05643df78ee6523ed52ad625fa01020b03ccb00cb8e421542f8754db64f9523c02628d8
7
- data.tar.gz: f8d7f58f064b379d6caa60f890c98479a8b08e7cfcfa421bbeff5ed70b74409bc73dc63e9638372f8360f3769c9d63b8b8804100ddf8725b30ba60a0187caed5
6
+ metadata.gz: 6a0e96bb5f22c9472ead1a903f0c9289f7aa0830f3f24a2c9cc579e7669668b1f8a8ec407e03b1e72d4cda2f94ea55dd872f9a8e59aea296b5da6371cbfcaaa5
7
+ data.tar.gz: 52e2ee1e54f56c353b7bf85f1f3de160b42a242d8efd770e252807551875ecf6630b043944f3babbcac4c4a6b80a175556495889b5d3b50bef868a5617309534
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # require the adapters
4
- Dir[File.dirname(__FILE__) + '/messaging_adapter/adapters/*.rb'].each { |file| require file }
4
+ Dir[File.dirname(__FILE__) + '/messaging_adapter/adapters/*.rb']
5
+ .each { |file| require file }
5
6
 
6
7
  module MessagingAdapter
7
8
  # MessageBroker class to create broker objects specifying the adapter type
@@ -29,19 +29,22 @@ module MessageBrokerAdapter
29
29
  exchange.publish(payload.to_json)
30
30
  end
31
31
 
32
- puts '- RMQ: Message published successfully on topic ' \
33
- "#{topic} [#{payload}]"
32
+ puts "- RMQ: Published #{payload.to_json} on #{topic}" if debug_mode?
34
33
  end
35
34
 
36
35
  def self.subscribe(queue, options = {})
37
36
  q = subscriber_channel.queue(queue, passive: true)
37
+
38
38
  options[:block] ||= options[:block].nil? ? true : options[:block]
39
- puts options[:block]
40
- q.subscribe(block: options[:block]) do |delivery_info, _properties, payload|
41
- yield(payload)
39
+ q.subscribe(block: options[:block]) do |_del_info, _props, payload|
40
+ yield(JSON.parse(payload))
42
41
  end
43
42
 
44
- puts "- RMQ: Subscribed successfully to the topic #{queue}"
43
+ puts "- RMQ: Subscribed successfully to the topic #{queue}" if debug_mode?
44
+ end
45
+
46
+ def self.debug_mode?
47
+ ENV['MessageBroker_Debug'] == 'true'
45
48
  end
46
49
 
47
50
  def self.connection_configs
@@ -72,7 +75,8 @@ module MessageBrokerAdapter
72
75
  def self.publisher_channel
73
76
  if Thread.current[:rmq_pub_channel].nil?
74
77
  pub_channel_locker.synchronize do
75
- Thread.current[:rmq_pub_channel] ||= publisher_connection.create_channel
78
+ Thread.current[:rmq_pub_channel] ||= publisher_connection
79
+ .create_channel
76
80
  end
77
81
  else
78
82
  Thread.current[:rmq_pub_channel]
@@ -93,7 +97,8 @@ module MessageBrokerAdapter
93
97
  def self.subscriber_channel
94
98
  if Thread.current[:rmq_sub_channel].nil?
95
99
  sub_channel_locker.synchronize do
96
- Thread.current[:rmq_sub_channel] ||= subscriber_connection.create_channel
100
+ Thread.current[:rmq_sub_channel] ||= subscriber_connection
101
+ .create_channel
97
102
  end
98
103
  else
99
104
  Thread.current[:rmq_sub_channel]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: messaging-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ayyoub Jadoo @ TAM