Home > Software design >  What are the semantics of `after_commit` for `ActiveJob`s?
What are the semantics of `after_commit` for `ActiveJob`s?

Time:01-11

I'm looking at some code and I see the equivalent of

SomeJob.perform_after_commit(foo, bar, baz)

and

class SomeJob < ActiveJob::Base
  def perform(foo, bar, baz)
    # does the thing
  end
end

My understanding of the after_commit callback is that it is relevant for ActiveRecords in order to run some callback after a transaction commits.

What does it mean for an ActiveJob? Does it default to executing immediately in the background - a "trivial transaction commit", if you will?

CodePudding user response:

you can use the gem ar_after_transaction, to execute code after all database transactions are closed.

  •  Tags:  
  • Related