stapfen 3.0.2.21 → 3.0.2.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGRlODBmYzg5OWFlNmMwYTdjYTc4MDkwY2ZiNzMyYTVhODY2YjgxNA==
4
+ Y2FlNzUwYjlhZDkyODRiMDNmOGJiMWVkMWRkOWZkMDc1MjMxMmU4NA==
5
5
  data.tar.gz: !binary |-
6
- NDQ0YTIwZjRlNjdiMzg4NTE3YThiZDZjOGJhOGFjZWI4OWM1ODg3Mw==
6
+ YjhjZWJjNDc2NDlmNDc1NjRkZWJmYTI4NThhOTgxMzlkZGI0MmRkYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzI4ZDUwNTg4OTA1ZGFkNWY5ZjVjMzU0N2E3NTFkOGI5ZTliYWI0NTliYzkz
10
- N2RhNGFjZDg2YjM4NmQ5YTllYjNmMDBiMGQ1MDAwOWFmYzM5NjVmNDk4ZWI3
11
- YTBjODk1N2RhMmUyMTMyZmE5MjNiZmI5ODAxZTA4ZDA1YjNjZjM=
9
+ MTFkMDg2ODZmMDcyMDBkMTFhOTgzYjM5YjA0NGVjMWVkYTlkMzhkMzk4NmY1
10
+ Yjc4OWZkMDRmYmQ4OTMwOWNkMDg2MDkxY2ZkYTRkYzVkYWI3YzIxYTY5NTAx
11
+ ODUwODk5ZWFjN2E5YzU2ZTcyZjhkNzE1YTU2OGU1ZDg4ZWMyMmE=
12
12
  data.tar.gz: !binary |-
13
- MTA3MTg2MTU4NWVhY2Y2YTlkY2QzOGJjOWMwNTVhNDFmNTk4ZTFkMTM3ZTM3
14
- OTBkNzk0ODdmNjBjODlkOTM3NzkzMjQwZDRkMzE4OTI0YWJlYTQ3MTEyMDA2
15
- ZTFjOWI4YjY5MzE3ZGUzNzgzOWFmMzM2MTlkNGEyMTQwY2Y5YTY=
13
+ MDkwNGMyNmM3ZjA2MjI0NzU2N2ExYWJmNDRhNmNlMmEzNjM0ZTUxOGYwZmM1
14
+ NDdhN2VkOTQ3NWUxOWFkZmVmZGY0MDhlNGJmOTA2YmZlMmU3ODdmYTIzMzFi
15
+ YmIxM2JmOTY1NzRmZjcwZTUxYWZlYzE2ZjhiMTVkOTMzYjllNTc=
@@ -101,9 +101,9 @@ module Stapfen
101
101
  # @option unreceive_headers [String] :dead_letter_queue After giving up on
102
102
  # redelivering, send the message here.
103
103
  def unreceive(message, unreceive_headers)
104
- return if unreceive_headers[:max_redeliveries].nil? && unreceive_headers[:max_redeliveries].nil?
104
+ return if unreceive_headers[:max_redeliveries].nil? && unreceive_headers[:dead_letter_queue].nil?
105
105
 
106
- destination = message.destination.to_s.sub('queue://','/queue/').sub('topic://','/topic')
106
+ destination = message.destination.to_s.sub('queue://','/queue/').sub('topic://','/topic/')
107
107
  retry_count = message.getStringProperty('retry_count').to_i || 0
108
108
  retry_count +=1
109
109
 
@@ -20,23 +20,49 @@ if RUBY_PLATFORM == 'java'
20
20
  let(:message) { double('Message', :destination => orig_destination, :data => body, :getStringProperty => nil) }
21
21
  let(:max_redeliveries) { 2 }
22
22
  let(:dlq) { '/queue/some_queue/dlq' }
23
- let(:unreceive_headers) do
24
- { :dead_letter_queue => dlq, :max_redeliveries => max_redeliveries }
25
- end
23
+
26
24
  let(:orig_destination) { '/queue/some_queue' }
27
25
 
28
26
  subject(:unreceive!) { client.unreceive(message, unreceive_headers) }
29
27
 
30
- context 'with no unreceive[:max_redeliveries] or unreceive[:dead_letter_queue]' do
28
+ context 'with no unreceive[:dead_letter_queue] and no unreceive[:max_redeliveries]' do
31
29
  let(:unreceive_headers) { Hash.new }
32
-
33
30
  it 'should not resend the message' do
34
31
  client.should_not_receive(:publish)
32
+ unreceive!
33
+ end
34
+ end
35
+
36
+ context 'with no unreceive[:max_redeliveries]' do
37
+ let(:unreceive_headers) do
38
+ { dead_letter_queue: '/queue/some_queue/dlq' }
39
+ end
35
40
 
41
+ it 'should resend the message' do
42
+ client.should_receive(:publish) do |dest, the_body, the_headers|
43
+ expect(dest).to eql '/queue/some_queue/dlq'
44
+ end
36
45
  unreceive!
37
46
  end
38
47
  end
39
48
 
49
+ context 'with no unreceive[:dead_letter_queue]' do
50
+ let(:unreceive_headers) { { max_redeliveries: 2 } }
51
+
52
+ it 'should resend the message' do
53
+ client.should_receive(:publish) do |dest, the_body, the_headers|
54
+ expect(dest).to eql orig_destination
55
+ expect(the_body).to eql body
56
+ end
57
+
58
+ unreceive!
59
+ end
60
+ end
61
+
62
+ let(:unreceive_headers) do
63
+ { :dead_letter_queue => dlq, :max_redeliveries => max_redeliveries }
64
+ end
65
+
40
66
  context 'On a message with no retry_count in the headers' do
41
67
  before :each do
42
68
  message.stub(:getStringProperty).with('retry_count').and_return(nil)
@@ -61,13 +87,10 @@ if RUBY_PLATFORM == 'java'
61
87
 
62
88
  context 'that is less than max_redeliveries' do
63
89
  let(:retry_count) { max_redeliveries - 1 }
64
-
65
90
  it 'should publish it to the same destination with a retry_count increased by one' do
66
91
  client.should_receive(:publish) do |dest, the_body, the_headers|
67
92
  expect(dest).to eql orig_destination
68
93
  expect(the_body).to eql body
69
-
70
-
71
94
  expect(the_headers).to eql({'retry_count' => (retry_count + 1).to_s})
72
95
  end
73
96
 
@@ -83,7 +106,6 @@ if RUBY_PLATFORM == 'java'
83
106
  client.should_receive(:publish) do |dest, the_body, the_headers|
84
107
  expect(the_body).to eql body
85
108
  expect(dest).to eql dlq
86
-
87
109
  expect(the_headers).to eql({:original_destination => orig_destination})
88
110
  end
89
111
 
@@ -105,6 +127,32 @@ if RUBY_PLATFORM == 'java'
105
127
  unreceive!
106
128
  end
107
129
  end
130
+
131
+ context 'with a topic url destination' do
132
+ let(:retry_count) { max_redeliveries + 1 }
133
+ let(:orig_destination) { 'topic://some_queue' }
134
+ it 'should succeed' do
135
+ client.should_receive(:publish) do |dest, the_body, the_headers|
136
+ expect(the_body).to eql body
137
+ expect(dest).to eql dlq
138
+ expect(the_headers).to eql({:original_destination => '/topic/some_queue'})
139
+ end
140
+ unreceive!
141
+ end
142
+ end
143
+
144
+ context 'with a queue url destination' do
145
+ let(:retry_count) { max_redeliveries + 1 }
146
+ let(:orig_destination) { 'queue://some_queue' }
147
+ it 'should succeed' do
148
+ client.should_receive(:publish) do |dest, the_body, the_headers|
149
+ expect(the_body).to eql body
150
+ expect(dest).to eql dlq
151
+ expect(the_headers).to eql({:original_destination => '/queue/some_queue'})
152
+ end
153
+ unreceive!
154
+ end
155
+ end
108
156
  end
109
157
  end
110
158
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stapfen
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2.21
4
+ version: 3.0.2.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - R. Tyler Croy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-08 00:00:00.000000000 Z
11
+ date: 2015-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thread_safe