Is Sidekiq suitable for tasks that are extremely important for completing missions, require one-time execution, require single-threaded execution?

Example script:

Payment processing and electronic product delivery transaction.

Requirements

  • There are approximately several thousand payment transactions per day that need to be completed. Each takes about 1 second. (Thus, the whole process will take about an hour)
  • Transactions should be processed linearly in one thread (the next transaction should not begin before the last transaction is completed, a strong FIFO order is required)
  • Each payment transaction is completed within the database transaction, everything that is returned to cancel the transaction, it is interrupted and placed in another queue for manual error handling. After that, he should continue processing the remaining transactions.

Order of importance

  • Single execution (if unsuccessful, placed in the error queue for manual processing)
  • Single thread
  • FIFO

Is Sidekiq suitable for such mission critical processes? Can sidekiq fully satisfy all these requirements? Or would you recommend other alternatives? Could you give me some recommendations on processing payments in rails?

Note: The question is not regarding whether to use stripe or ActiveMerchant for payment handling. It is more about the safest way to programmatically execute those processes in the background.

+4
source share
2 answers

, Sidekiq .

, Sidekiq concurrency 1, . , .

, , Sidekiq Failures , .

, Sidekiq Pro . Sidekiq , , . , , , Sidekiq . , . (, , Sidekiq Redis, .)

Ruby , Sidekiq, , . Ruby, , Sidekiq .

+4

, , .

class Worker
  include Sidekiq::Worker

  def perform(*params)
    # do work, raising exception if necessary

    NextWorker.perform_async(params, here)
  end
end
0

All Articles