rabbit_jobs 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,7 @@ module RabbitJobs
10
10
  end
11
11
 
12
12
  def main_loop(time)
13
- while true
13
+ loop do
14
14
  sleep 1
15
15
  if time > 0
16
16
  time -= 1
@@ -22,8 +22,8 @@ module RabbitJobs
22
22
  def direct_publish_to(routing_key, payload, ex = {})
23
23
  check_connection
24
24
  begin
25
- exchange_name = (ex.delete(:name) rescue nil).to_s # rescue for frozen hash
26
25
  exchange_opts = Configuration::DEFAULT_MESSAGE_PARAMS.merge(ex || {})
26
+ exchange_name = exchange_opts.delete(:name).to_s
27
27
  connection.default_channel.basic_publish(payload, exchange_name, routing_key, exchange_opts)
28
28
  rescue
29
29
  RabbitJobs.logger.warn $!.message
@@ -36,6 +36,7 @@ module RabbitJobs
36
36
 
37
37
  def purge_queue(*routing_keys)
38
38
  raise ArgumentError unless routing_keys.present?
39
+ check_connection
39
40
 
40
41
  messages_count = 0
41
42
  routing_keys.map(&:to_sym).each do |routing_key|
@@ -57,6 +58,7 @@ module RabbitJobs
57
58
  unless settings[:connection]
58
59
  settings[:connection] = Bunny.new(RabbitJobs.config.server, :heartbeat_interval => 5)
59
60
  settings[:connection].start
61
+ # settings[:channel] = settings[:connection].create_channel
60
62
  # settings[:channel].confirm_select
61
63
  end
62
64
  settings[:connection]
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  module RabbitJobs
4
- VERSION = "0.8.4"
4
+ VERSION = "0.8.5"
5
5
  end
@@ -60,7 +60,7 @@ module RabbitJobs
60
60
 
61
61
  begin
62
62
  amqp_channel = amqp_connection.create_channel
63
- amqp_channel.prefetch(1)
63
+ # amqp_channel.prefetch(1)
64
64
 
65
65
  queues.each do |routing_key|
66
66
  consume_queue(amqp_channel, routing_key)
@@ -118,9 +118,10 @@ module RabbitJobs
118
118
 
119
119
  queue.subscribe(ack: explicit_ack) do |delivery_info, properties, payload|
120
120
  if consume_message(delivery_info, properties, payload)
121
- amqp_channel.ack(delivery_info.delivery_tag, false) if explicit_ack
121
+ amqp_channel.ack(delivery_info.delivery_tag) if explicit_ack
122
122
  else
123
- amqp_channel.nack(delivery_info.delivery_tag, true) if explicit_ack
123
+ requeue = false
124
+ amqp_channel.nack(delivery_info.delivery_tag, requeue) if explicit_ack
124
125
  end
125
126
  end
126
127
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabbit_jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.8.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-27 00:00:00.000000000 Z
12
+ date: 2013-03-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bunny
16
- requirement: &10058300 !ruby/object:Gem::Requirement
16
+ requirement: &15186800 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - =
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.9.0.pre8
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *10058300
24
+ version_requirements: *15186800
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &10057900 !ruby/object:Gem::Requirement
27
+ requirement: &15186260 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *10057900
35
+ version_requirements: *15186260
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rufus-scheduler
38
- requirement: &10057240 !ruby/object:Gem::Requirement
38
+ requirement: &15185680 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '2.0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *10057240
46
+ version_requirements: *15185680
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rails
49
- requirement: &10056660 !ruby/object:Gem::Requirement
49
+ requirement: &15185020 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '3.0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *10056660
57
+ version_requirements: *15185020
58
58
  description: Background jobs on RabbitMQ
59
59
  email:
60
60
  - lazureykis@gmail.com
@@ -117,7 +117,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  segments:
119
119
  - 0
120
- hash: -1879492991385784820
120
+ hash: -1922463039954072694
121
121
  required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  none: false
123
123
  requirements:
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  segments:
128
128
  - 0
129
- hash: -1879492991385784820
129
+ hash: -1922463039954072694
130
130
  requirements: []
131
131
  rubyforge_project:
132
132
  rubygems_version: 1.8.11