Logan
Logan

Reputation: 1682

What are the semantics of `after_commit` for `ActiveJob`s?

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?

Upvotes: 1

Views: 317

Answers (1)

Yoav Epstein
Yoav Epstein

Reputation: 859

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

Upvotes: 1

Related Questions