smart-que 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/smart_que.rb +13 -3
- data/lib/smart_que/errors.rb +6 -0
- data/lib/smart_que/publisher.rb +11 -5
- data/lib/smart_que/publishers/base.rb +8 -2
- data/lib/smart_que/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f937567bd226a31740b995a1ef2c2e44c4ca2ce
|
4
|
+
data.tar.gz: 3efb11d3b6496d4a142e77f87c61bbc52b81426d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e46437187be14cb152842dbd34c7a96fb8bfb9ed99d90f1c07765f601f235e629d88e8cf61f560666219411fc85fcbf32a8e0bbde52edfb39514d8a8ac8bfecc
|
7
|
+
data.tar.gz: 4b23b76bcd51eb1ab855ad4cce5b1378117d833efdeb11baddfb9d456d617a637454674c27ba51233344c09d534f5b73e7f9381c9315986678e8c74908e431c1
|
data/lib/smart_que.rb
CHANGED
@@ -31,8 +31,8 @@ module SmartQue
|
|
31
31
|
|
32
32
|
@conn_pool.with do |conn|
|
33
33
|
# Reestablish connection if closed
|
34
|
-
|
35
|
-
conn
|
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
|
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 = {})
|
data/lib/smart_que/errors.rb
CHANGED
data/lib/smart_que/publisher.rb
CHANGED
@@ -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
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
-
#
|
13
|
-
if @channel.
|
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
|
data/lib/smart_que/version.rb
CHANGED
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
|
+
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-
|
11
|
+
date: 2018-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|