smart-que 0.2.4 → 0.2.5

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: d1bd51aadd5975296cea9f91b4dc5a2ee8eabf41
4
- data.tar.gz: b3129e1bd3c29c76b0de0d3f21477584541a61b8
3
+ metadata.gz: 6f937567bd226a31740b995a1ef2c2e44c4ca2ce
4
+ data.tar.gz: 3efb11d3b6496d4a142e77f87c61bbc52b81426d
5
5
  SHA512:
6
- metadata.gz: ec96c1915582d8217de71c79326c4b2f2336711bfa59e7e4ae67772eb1d83ee6bd31ae200f58f2063b233d9b02beb390d195a88df1ea838218fdbabbc5b9b9ad
7
- data.tar.gz: 12556476f004eb37ed2e23d39c4f2a8a134cae9497809357e94a3acac45e0fc249e0d5744fd32881069efb10cd51b65298360ee0e4c3588f20cf52411b5c686d
6
+ metadata.gz: e46437187be14cb152842dbd34c7a96fb8bfb9ed99d90f1c07765f601f235e629d88e8cf61f560666219411fc85fcbf32a8e0bbde52edfb39514d8a8ac8bfecc
7
+ data.tar.gz: 4b23b76bcd51eb1ab855ad4cce5b1378117d833efdeb11baddfb9d456d617a637454674c27ba51233344c09d534f5b73e7f9381c9315986678e8c74908e431c1
@@ -31,8 +31,8 @@ module SmartQue
31
31
 
32
32
  @conn_pool.with do |conn|
33
33
  # Reestablish connection if closed
34
- unless conn.open?
35
- conn.start
34
+ if !conn.open? && !conn.automatically_recover?
35
+ connect(conn)
36
36
  end
37
37
  # Return connection object
38
38
  conn
@@ -47,7 +47,17 @@ module SmartQue
47
47
  username: config.username,
48
48
  password: config.password
49
49
  )
50
- conn.start
50
+ connect(conn)
51
+ end
52
+
53
+ # Start & Connect Bunny Session
54
+ def self.connect(session)
55
+ begin
56
+ session.start
57
+ rescue Bunny::TCPConnectionFailed => ex
58
+ log("Connection Failed: #{ex.message}")
59
+ raise ConnectionError
60
+ end
51
61
  end
52
62
 
53
63
  def self.fetch_parameters(parameter, options = {})
@@ -4,4 +4,10 @@ module SmartQue
4
4
  "Queue doesn't exist"
5
5
  end
6
6
  end
7
+
8
+ class ConnectionError < StandardError
9
+ def message
10
+ "Broken connection failed"
11
+ end
12
+ end
7
13
  end
@@ -43,11 +43,17 @@ module SmartQue
43
43
 
44
44
  # multicast message to queues based on topic subscription
45
45
  def multicast(topic, payload = {})
46
- x_topic.publish(
47
- payload.to_json,
48
- routing_key: dot_formatted(topic)
49
- )
50
- log_message("multicast status: success, Topic : #{topic}, Content : #{payload}")
46
+ begin
47
+ x_topic.publish(
48
+ payload.to_json,
49
+ routing_key: dot_formatted(topic)
50
+ )
51
+ log_message("multicast status: success, Topic : #{topic}, Content : #{payload}")
52
+ :success
53
+ rescue => ex
54
+ log("#{ex.message}")
55
+ :error
56
+ end
51
57
  end
52
58
 
53
59
  # broadcast message to queues based on topic subscription
@@ -3,14 +3,20 @@ require 'connection_pool'
3
3
  module SmartQue
4
4
  module Publishers
5
5
  class Base
6
+
6
7
  # List Queues from configuration
7
8
  def queue_list
8
9
  ::SmartQue.config.queues
9
10
  end
10
11
 
11
12
  def channel
12
- # Create new channel if closed
13
- if @channel.nil? || @channel.closed?
13
+ # Raise exception if connection is not_connected or closed
14
+ if @channel && (!@channel.open? || !@channel.connection.open?)
15
+ raise ConnectionError
16
+ end
17
+
18
+ # # Create new channel if closed
19
+ if @channel.nil? # && connection.open?
14
20
  @channel = connection.create_channel
15
21
  end
16
22
  @channel
@@ -1,3 +1,3 @@
1
1
  module SmartQue
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart-que
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ashik Salman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-02 00:00:00.000000000 Z
11
+ date: 2018-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny