我正在关注this gem doc,我想知道哪里出了问题。 宝石版本: rails版本:6.0
{
"name": "my-app",
"version": "#{Build.BuildNumber}#",
"instance": "localdev",
"firebaseConfig": {
"apiKey": "abcd"
...
}
}
这是sidekiq (5.2.8)
connection_pool (~> 2.2, >= 2.2.2)
rack (< 2.1.0
rack-protection (>= 1.5.0)
redis (>= 3.3.5, < 5)
sidekiq-bus (0.9.0)
queue-bus (>= 0.7, < 1)
sidekiq (~> 5.0, >= 3.0.0)
sidekiq-scheduler (~> 3.0)
rake queuebus:subscribe
我正在发布** Invoke queuebus:subscribe (first_time)
** Invoke queuebus:preload (first_time)
** Execute queuebus:preload
** Execute queuebus:subscribe
rake aborted!
No subscriptions created
/Users/Imi/.rvm/gems/ruby-2.6.0/gems/queue-bus-0.9.0/lib/queue_bus/tasks.rb:10:in `block (2 levels) in <top (required)>'
/Users/Imi/.rvm/gems/ruby-2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `block in execute'
/Users/Imi/.rvm/gems/ruby-2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `each'
/Users/Imi/.rvm/gems/ruby-2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `execute'
/Users/Imi/.rvm/gems/ruby-2.6.0/gems/rake-13.0.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/Users/Imi/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/monitor.rb:230:in `mon_synchronize'
/Users/Imi/.rvm/gems/ruby-2.6.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/Imi/.rvm/gems/ruby-2.6.0/gems/rake-13.0.1/lib/rake/task.rb:188:in `invoke'
/Users/Imi/.rvm/gems/ruby-2.6.0/gems/rake-13.0.1/lib/rake/application.rb:160:in `invoke_task'
/Users/Imi/.rvm/gems/ruby-2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/Users/Imi/.rvm/gems/ruby-2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `each'
/Users/Imi/.rvm/gems/ruby-2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block in top_level'
/Users/Imi/.rvm/gems/ruby-2.6.0/gems/rake-13.0.1/lib/rake/application.rb:125:in `run_with_threads'
/Users/Imi/.rvm/gems/ruby-2.6.0/gems/rake-13.0.1/lib/rake/application.rb:110:in `top_level'
/Users/Imi/.rvm/gems/ruby-2.6.0/gems/rake-13.0.1/lib/rake/application.rb:83:in `block in run'
/Users/Imi/.rvm/gems/ruby-2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/Imi/.rvm/gems/ruby-2.6.0/gems/rake-13.0.1/lib/rake/application.rb:80:in `run'
/Users/Imi/.rvm/gems/ruby-2.6.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/Users/Imi/.rvm/gems/ruby-2.6.0/bin/rake:23:in `load'
/Users/Imi/.rvm/gems/ruby-2.6.0/bin/rake:23:in `<main>'
/Users/Imi/.rvm/gems/ruby-2.6.0/bin/ruby_executable_hooks:24:in `eval'
/Users/Imi/.rvm/gems/ruby-2.6.0/bin/ruby_executable_hooks:24:in `<main>'
Tasks: TOP => queuebus:subscribe
中的事件(QueueBus.publish('concern_created', phone: '0000000005')
)。一旦我发布事件,sidekiq中的已处理事件数就会增加一。
subscribers / base_subscriber.rb
rails console
subscribers / concern_subscriber.rb
class BaseSubscriber
include QueueBus::Subscriber
application :concern_api
end
初始化程序/sidekiq.rb
class ConcernSubscriber < BaseSubscriber
subscribe_queue :concern_events, :concern_created
def concern_created(attr)
put "******" * 20
PartnerInvitation.create!({phone: attr['phone']})
end
end
config / sidekiq.yml
require 'sidekiq'
require 'sidekiq/web'
Sidekiq.configure_server do |config|
config.redis = { url: Rails.application.config_for(:redis)[:url] }
end
Sidekiq.configure_client do |config|
config.redis = { url: Rails.application.config_for(:redis)[:url] }
end
# https://github.com/queue-bus/sidekiq-bus
if Sidekiq.server?
# Load the queues into sidekiq:
weights = {
'app_events' => 10,
'app_heartbeat' => 3,
'app_refresh' => 1
}
Sidekiq.options[:queues] = SidekiqBus.generate_weighted_queues(overrides: weights, default: 2)
end
注意:::verbose: true
:timeout: 25
:queues:
- critical
- concern_events
- default
- low
仅返回rake queuebus:queues