Skip to content
Mike Perham edited this page Mar 17, 2017 · 6 revisions

FAQ

Why do Sidekiq Pro batch callbacks run without a tenant?

Make sure Apartment's server-side middleware comes before the Batch middleware. Put this in your initializer to rejigger it's location.

Sidekiq.configure_server do |config|
  config.server_middleware do |chain|
    chain.insert_before Sidekiq::Batch::Server, Apartment::Sidekiq::Middleware::Server
  end
end

You can see the current state of your middleware chains when you start Sidekiq with -v.

2017-03-17T00:01:25.728Z 8082 TID-owji388x0 DEBUG: Client Middleware: Sidekiq::Batch::Client, Apartment::Sidekiq::Middleware::Client, Sidekiq::Enterprise::Unique::Client, Sidekiq::Enterprise::Crypto::Client
2017-03-17T00:01:25.728Z 8082 TID-owji388x0 DEBUG: Server Middleware: Sidekiq::Middleware::Server::RetryJobs, Sidekiq::Middleware::Server::Logging, Sidekiq::Limiter::Middleware, Sidekiq::Enterprise::Unique::Server, Sidekiq::Batch::Server, Apartment::Sidekiq::Middleware::Server, Sidekiq::Enterprise::Crypto::Server

Fixed:

2017-03-17T00:04:30.886Z 8127 TID-ovsmi505w DEBUG: Server Middleware: Sidekiq::Middleware::Server::RetryJobs, Sidekiq::Middleware::Server::Logging, Sidekiq::Limiter::Middleware, Sidekiq::Enterprise::Unique::Server, Apartment::Sidekiq::Middleware::Server, Sidekiq::Batch::Server, Sidekiq::Enterprise::Crypto::Server
Clone this wiki locally