smart-que 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f937567bd226a31740b995a1ef2c2e44c4ca2ce
4
- data.tar.gz: 3efb11d3b6496d4a142e77f87c61bbc52b81426d
3
+ metadata.gz: fbcbe208404fb52eac11166bed6c4474a164c6ad
4
+ data.tar.gz: 060e6dcb5170fb96db495d9d9f22c730c1866e53
5
5
  SHA512:
6
- metadata.gz: e46437187be14cb152842dbd34c7a96fb8bfb9ed99d90f1c07765f601f235e629d88e8cf61f560666219411fc85fcbf32a8e0bbde52edfb39514d8a8ac8bfecc
7
- data.tar.gz: 4b23b76bcd51eb1ab855ad4cce5b1378117d833efdeb11baddfb9d456d617a637454674c27ba51233344c09d534f5b73e7f9381c9315986678e8c74908e431c1
6
+ metadata.gz: a1a8e5a3b43f1a0ac2173ce437338dd711557053e51269b27171beab808652eab951b745cbc2e81cb07aa8c9c54448445e7487afb4023921d82577e66d259bc3
7
+ data.tar.gz: c31e06758cea569338d844396ead80e006a27cd4710357112206fd2d75941d2f235e9f8e131dab75a57e5bacca7af24753120f4553e7e6e71ab60d1b7956e362
data/README.md CHANGED
@@ -8,7 +8,7 @@ to publish and consume messages with defined queues.
8
8
  Add this line to your application's Gemfile:
9
9
 
10
10
  ```ruby
11
- gem 'smart-que', '~> 0.2.0'
11
+ gem 'smart-que', '~> 0.2.6'
12
12
  ```
13
13
 
14
14
  And then execute:
@@ -17,7 +17,7 @@ And then execute:
17
17
 
18
18
  Or install it yourself as:
19
19
 
20
- $ gem install smart-que -v 0.2.0
20
+ $ gem install smart-que -v 0.2.6
21
21
 
22
22
  ## Usage
23
23
 
@@ -34,6 +34,7 @@ RabbitMq server details and queue lists can be configured as follows
34
34
 
35
35
  ```
36
36
  # File: config/initializers/smart_que.rb
37
+ require 'smart_que'
37
38
 
38
39
  SmartQue.configure do |f|
39
40
  f.host = ENV[:rabbit_mq][:host']
@@ -73,7 +74,7 @@ $publisher.unicast(queue_name, payload)
73
74
 
74
75
  The `unicast` method will provide an option to publish message to any queue which are
75
76
  not predefined with initialization configuration. The `queue_name` parameter can be any queue
76
- name, which will be created and bind to direct exchange instantly if doesn't exist.
77
+ name, which will be created and bound to direct exchange instantly if doesn't exist.
77
78
 
78
79
  ```
79
80
  $publisher.unicast('sms_alert', { number: '+919898123123', message: 'Test Message' })
@@ -96,6 +97,20 @@ name.
96
97
  $publisher.multicast('weather', { message: 'Test Message' })
97
98
  ```
98
99
 
100
+ ## SmartQue broadcast
101
+
102
+ ```
103
+ $publisher.broadcast(payload)
104
+ ```
105
+
106
+ The `broadcast` method will provide an option to broadcast message to queues which are
107
+ not predefined with initialization configuration. The broadcst message will be consumable by
108
+ all queues which are bound to rabbitmq fanout exchange.
109
+
110
+ ```
111
+ $publisher.broadcast({ message: 'Broadcast Test Message' })
112
+ ```
113
+
99
114
 
100
115
  ## SmartQue Consumer
101
116
 
@@ -143,6 +158,12 @@ end
143
158
  RAILS_ENV=staging bundle exec rake rabbitmq:send_otp_sms
144
159
  ```
145
160
 
161
+ ## SmartQue Exceptions
162
+
163
+ SmartQue will not retry automatic connection recovery after rabbitmq connection failure. It raises
164
+ `SmartQue::ConnectionError` when tcp connection failure happens. You can catch this exception to
165
+ identify connection failures and can perform necessary actions upon it.
166
+
146
167
  ## RabbitMq Web Interface
147
168
 
148
169
  You can enable rabbitmq_management plugin so that rabbitmq server informations
@@ -18,12 +18,18 @@ module SmartQue
18
18
  # Return if queue doesn't exist
19
19
  if queue_list.include? queue
20
20
  # Publish sms to queue
21
- x_direct.publish(
22
- payload.to_json,
23
- mandatory: true,
24
- routing_key: get_queue(queue).name
25
- )
26
- log_message("Publish status: success, Queue : #{queue}, Content : #{payload}")
21
+ begin
22
+ x_direct.publish(
23
+ payload.to_json,
24
+ mandatory: true,
25
+ routing_key: get_queue(queue).name
26
+ )
27
+ log_message("Publish status: success, Queue : #{queue}, Content : #{payload}")
28
+ :success
29
+ rescue => ex
30
+ log_message("Publish error:#{ex.message}")
31
+ :error
32
+ end
27
33
  else
28
34
  log_message("Publish status: failed, Queue(#{queue}) doesn't exist.")
29
35
  log_message("Content : #{payload}")
@@ -33,11 +39,17 @@ module SmartQue
33
39
 
34
40
  # unicast message to queues
35
41
  def unicast(q_name, payload = {})
36
- x_default.publish(
37
- payload.to_json,
38
- routing_key: dot_formatted(q_name)
39
- )
40
- log_message("unicast status: success, Queue : #{q_name}, Content : #{payload}")
42
+ begin
43
+ x_default.publish(
44
+ payload.to_json,
45
+ routing_key: dot_formatted(q_name)
46
+ )
47
+ log_message("unicast status: success, Queue : #{q_name}, Content : #{payload}")
48
+ :success
49
+ rescue => ex
50
+ log_message("Unicast error:#{ex.message}")
51
+ :error
52
+ end
41
53
  end
42
54
 
43
55
 
@@ -51,17 +63,23 @@ module SmartQue
51
63
  log_message("multicast status: success, Topic : #{topic}, Content : #{payload}")
52
64
  :success
53
65
  rescue => ex
54
- log("#{ex.message}")
66
+ log_message("Multicast error:#{ex.message}")
55
67
  :error
56
68
  end
57
69
  end
58
70
 
59
71
  # broadcast message to queues based on topic subscription
60
72
  def broadcast(payload = {})
61
- x_fanout.publish(
62
- payload.to_json
63
- )
64
- log_message("broadcast status: success, Content : #{payload}")
73
+ begin
74
+ x_fanout.publish(
75
+ payload.to_json
76
+ )
77
+ log_message("broadcast status: success, Content : #{payload}")
78
+ :success
79
+ rescue => ex
80
+ log_message("Broadcast error:#{ex.message}")
81
+ :error
82
+ end
65
83
  end
66
84
  end
67
85
  end
@@ -1,3 +1,3 @@
1
1
  module SmartQue
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart-que
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ashik Salman