message 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +11 -1
  2. data/lib/message/worker.rb +2 -0
  3. metadata +2 -2
data/README.md CHANGED
@@ -26,13 +26,15 @@ Add an initializer config/initializers/message.rb
26
26
 
27
27
  Message.logger = Rails.logger
28
28
  # Setup default job queue name, default: "message-worker-default"
29
- Message.worker.default_job = "app-name-#{Rails.env}-message-worker-default"
29
+ Message.worker.default_job = "app-name-#{ENV['MESSAGE_NAMESPACE']}-message-worker-default"
30
30
  # Bypass queue system and process job synchronously when you called .async
31
31
  # default: false
32
32
  Message.worker.sync = !Rails.env.production?
33
33
  # Change to sqs adapter for asynchronous calls, default is a thread-safe in memory queue named :in_memory
34
34
  Message.queue.adapter = :sqs
35
35
 
36
+ Start worker thread for JRuby in config/initializers/message.rb:
37
+
36
38
  # Start a worker thread in production
37
39
  if Rails.env.production? && $0 !~ /rake$/
38
40
  # Sleep 15 seconds for processed every 10 jobs or less
@@ -40,6 +42,14 @@ Add an initializer config/initializers/message.rb
40
42
  Message.worker.start(:size => 10, :interval => 15)
41
43
  end
42
44
 
45
+ Add a rake task for start worker process
46
+
47
+ namespace :message do
48
+ task :worker do
49
+ Message.worker.start(:size => 10, :interval => 15).join
50
+ end
51
+ end
52
+
43
53
  ### Queuing jobs
44
54
 
45
55
 
@@ -68,9 +68,11 @@ module Message
68
68
  def start(options={})
69
69
  size = options[:size] || DEFAULT_PROCESS_SIZE
70
70
  interval = options[:interval] || DEFAULT_PROCESS_INTERVAL
71
+ delay = options[:delay] || 10 + rand(20)
71
72
  Thread.start do
72
73
  begin
73
74
  log(:info) { "start" }
75
+ sleep delay
74
76
  loop do
75
77
  process(size)
76
78
  sleep interval
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: message
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-09-14 00:00:00.000000000 Z
12
+ date: 2014-09-18 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! 'Message provides flexible & reliable background/asynchronous job processing
15
15
  mechanism on top of simple queue interface.