nebulous_stomp 2.0.0 → 2.0.1

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: b50d86922e77fc4e61bf8a69424f252d3c91ce41
4
- data.tar.gz: 62790af2e03505a506da7f73ff7e772c17d09b16
3
+ metadata.gz: 210d0ff5d3c99590ab6356e5456e2fa67e9ab0ae
4
+ data.tar.gz: ac6782c4ef1969f7f0854de505a393927487cd00
5
5
  SHA512:
6
- metadata.gz: 78f6c7775d04afca9ef387767ad4e7bf3e0f54d37b276cd653ebbccd3297f76f969b376616554855fd90497c30372e1b3716cf44afae53fa07107b6f686684c0
7
- data.tar.gz: a085cc52937b783362bc4669797f589aac716a1af5a27fd1a34c674d3d20020fc053a6a89706fef075f0966cfa477f05e93981f09cf167ed9aeffc01642684b6
6
+ metadata.gz: e12b2880dff2e61135575fcb2f694315621fcd8a69f29156e01eec0d1248b8f679241d1907bf75da452ec3bb6cf69152009e364ed9aeaa218b2735c929a7daf2
7
+ data.tar.gz: 2e5a0161b8c527dd8633562d1f359b781e105554a4c4d396c2dcba265f78750c0697051d0049cc9f26e6ef060b68cc97358d358e64a6caa1d0a64d3065922f92
data/.hgtags CHANGED
@@ -15,3 +15,4 @@ cff04defabb0895ff2f032087b97ea9616bee6a9 1.14
15
15
  8ad003b30ff2d61d481343ba8d822ff2ffafaabb 1.1.4
16
16
  6ddf180c9a2fc1cef55f5d128faa4d5df28d1353 1.1.5
17
17
  6da65ce15fab9722deb05d8c0ed2d0c8e2cfe2ff 2.0.0
18
+ 9c4ec9af8f6b8a848082bf118be037696ff357c7 2.0.1
@@ -2,12 +2,15 @@ require 'stomp'
2
2
  require 'json'
3
3
  require 'time'
4
4
 
5
-
6
5
  module NebulousStomp
7
6
 
8
7
 
9
8
  ##
10
- # A Class to deal with talking to STOMP via the Stomp gem
9
+ # A Class to deal with talking to STOMP via the Stomp gem.
10
+ #
11
+ # You will need to instantiate this yourself if you only want to listen for messages. But if you
12
+ # want to send a request and receive a response, you should never need this -- a NebRequest
13
+ # returns a Message.
11
14
  #
12
15
  class StompHandler
13
16
 
@@ -123,7 +126,7 @@ module NebulousStomp
123
126
  return self unless nebulous_on?
124
127
  NebulousStomp.logger.info(__FILE__) {"Connecting to STOMP"}
125
128
 
126
- @client = @test_client || Stomp::Client.new( @stomp_hash.dup )
129
+ @client = @test_client || Stomp::Client.new( @stomp_hash )
127
130
  raise ConnectionError, "Stomp Connection failed" unless connected?
128
131
 
129
132
  conn = @client.connection_frame()
@@ -208,9 +211,6 @@ module NebulousStomp
208
211
  # Ideally I'd like to DRY this and listen() up, but with this
209
212
  # yield-within-a-thread stuff going on, I'm actually not sure how to do
210
213
  # that safely.
211
- #
212
- # Actually i'm not even sure how to stop once I've read one message. The
213
- # Stomp gem behaves very strangely.
214
214
  #++
215
215
  #
216
216
  def listen_with_timeout(queue, timeout)
@@ -230,21 +230,24 @@ module NebulousStomp
230
230
  @client.subscribe( queue, {ack: "client-individual"} ) do |msg|
231
231
 
232
232
  begin
233
- if msg.body == 'boo'
234
- @client.ack(msg)
235
- elsif done == false
233
+ unless msg.body == "boo"
236
234
  yield Message.from_stomp(msg)
237
235
  done = true
238
236
  end
237
+ @client.ack(msg)
239
238
  rescue =>e
240
239
  NebulousStomp.logger.error(__FILE__) {"Error during polling: #{e}" }
241
240
  end
242
241
 
243
- end # of Stomp client subscribe block
242
+ if done
243
+ # Not that this seems to do any good when the Stomp gem is in play
244
+ resource.signal
245
+ break
246
+ end
244
247
 
245
- # Not that this seems to do any good when the Stomp gem is in play, but.
246
- resource.signal if done
248
+ end # of Stomp client subscribe block
247
249
 
250
+ resource.signal if done #or here. either, but.
248
251
  end # of with_timeout
249
252
 
250
253
  raise NebulousTimeout unless done
@@ -261,7 +264,10 @@ module NebulousStomp
261
264
  && mess.respond_to?(:headers_for_stomp)
262
265
 
263
266
  stomp_connect unless @client
264
- @client.publish(queue, mess.body_for_stomp, mess.headers_for_stomp)
267
+
268
+ headers = mess.headers_for_stomp.reject{|k,v| v.nil? || v == "" }
269
+ @client.publish(queue, mess.body_for_stomp, headers)
270
+
265
271
  mess
266
272
  end
267
273
 
@@ -1,5 +1,5 @@
1
1
  module NebulousStomp
2
2
 
3
3
  # Nebulous version number
4
- VERSION = "2.0.0"
4
+ VERSION = "2.0.1"
5
5
  end
data/nebulous.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.requirements << 'Redis server (optional)'
29
29
 
30
30
  spec.post_install_message = <<~MESSAGE
31
- Nebulous has been installed ...sort of... ::waves arms noncomittedly::
31
+ Nebulous has been installed ...sort of... ::waves arms noncomittedly::
32
32
  MESSAGE
33
33
 
34
34
  spec.add_development_dependency "bundler", "~> 1.11"
@@ -39,8 +39,8 @@ Gem::Specification.new do |spec|
39
39
  spec.add_development_dependency "pry-doc"
40
40
  spec.add_development_dependency "ripper-tags"
41
41
 
42
- spec.add_runtime_dependency 'stomp', '>=1.3'
43
- spec.add_runtime_dependency 'redis', '>=3.1'
42
+ spec.add_runtime_dependency 'stomp', '~>1.4'
43
+ spec.add_runtime_dependency 'redis', '~>3.1'
44
44
  spec.add_runtime_dependency 'devnull', '~>0.1'
45
45
 
46
46
  end
@@ -0,0 +1,79 @@
1
+ require 'nebulous_stomp'
2
+
3
+
4
+ ##
5
+ # This is a through test against the JH development stomp server.
6
+ # It's really only here to double check that the Stomp gem hasn't moved the
7
+ # goalposts (again).
8
+ #
9
+ # In order for it to work, the JH RabbitMQ server has to be where we left it.
10
+ # So this test won't work for you out of the box, unless you are me.
11
+ #
12
+ describe 'through test' do
13
+
14
+ def connect_hash
15
+ host = { login: 'guest',
16
+ passcode: 'guest',
17
+ host: '10.0.0.150',
18
+ port: 61613,
19
+ ssl: false }
20
+
21
+ {hosts: [host], reliable: false}
22
+ end
23
+
24
+ def target_hash
25
+ { sendQueue: "/queue/nebulous.test",
26
+ receiveQueue: "/queue/nebulous.test.response" }
27
+
28
+ end
29
+
30
+ def init_stomp
31
+ NebulousStomp.init(stompConnectHash: connect_hash, messageTimeout: 5)
32
+ NebulousStomp.add_target(:target, target_hash)
33
+ end
34
+
35
+ ##
36
+ # a little method to receive a message and send one back, for testinng
37
+ # sending one.
38
+ #
39
+ def qna
40
+ Thread.new do
41
+
42
+ begin
43
+ sh = NebulousStomp::StompHandler.new(connect_hash)
44
+ sh.listen_with_timeout( target_hash[:sendQueue], 10 ) do |m|
45
+ sh.send_message( *m.respond_success )
46
+ end
47
+ ensure
48
+ sh.stomp_disconnect if sh
49
+ end
50
+
51
+ end
52
+
53
+ rescue
54
+ nil
55
+ end
56
+
57
+
58
+ let(:request) { NebulousStomp::NebRequest.new(:target, "ping") }
59
+
60
+ before do
61
+ init_stomp
62
+ end
63
+
64
+
65
+ it "sends a request" do
66
+ expect{ request.send_no_cache }.to raise_exception NebulousStomp::NebulousTimeout
67
+ end
68
+
69
+
70
+ it "receives a response" do
71
+ r = NebulousStomp::NebRequest.new(:target, "ping")
72
+ qna; response = r.send_no_cache
73
+
74
+ expect( response ).to be_a_kind_of NebulousStomp::Message
75
+ expect( response.verb ).to eq 'success'
76
+ end
77
+
78
+ end
79
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nebulous_stomp
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Jones
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-06 00:00:00.000000000 Z
11
+ date: 2016-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -112,28 +112,28 @@ dependencies:
112
112
  name: stomp
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '1.3'
117
+ version: '1.4'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '1.3'
124
+ version: '1.4'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: redis
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
131
  version: '3.1'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '3.1'
139
139
  - !ruby/object:Gem::Dependency
@@ -199,12 +199,13 @@ files:
199
199
  - spec/spec_helper.rb
200
200
  - spec/stomp_handler_null_spec.rb
201
201
  - spec/stomp_handler_spec.rb
202
+ - spec/through_test_spec.rb
202
203
  - tags
203
204
  homepage: https://bitbucket.org/andy-twosticks/nebulous_stomp
204
205
  licenses:
205
206
  - MIT
206
207
  metadata: {}
207
- post_install_message: 'Nebulous has been installed ...sort of... ::waves arms noncomittedly::
208
+ post_install_message: 'Nebulous has been installed ...sort of... ::waves arms noncomittedly::
208
209
 
209
210
  '
210
211
  rdoc_options: []
@@ -241,4 +242,5 @@ test_files:
241
242
  - spec/spec_helper.rb
242
243
  - spec/stomp_handler_null_spec.rb
243
244
  - spec/stomp_handler_spec.rb
245
+ - spec/through_test_spec.rb
244
246
  has_rdoc: