Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My configuration is correct or not. Because uniq job not remove all job process in sidekiq ? #767

Open
hardik355 opened this issue Mar 30, 2023 · 0 comments

Comments

@hardik355
Copy link

Right now I have many duplicate jobs, So, I want to remove the job before enqueue. I have sidekiq throttle worker.

Here is my config.
ruby '3.1.2'
'rails', '~> 6.0.2'
'sidekiq', '~> 6.4.1'
'sidekiq-throttled'
'sidekiq-unique-jobs', '~> 7.1.2'

sidekiq_options :queue => :default, :backtrace => 10, :failures => :exhausted, lock: :until_executed, unique_args: :unique_args, log_duplicate_payload: true, unique_across_queues: true

def self.unique_args(args)
  if worker_args['service'].eql?('Inventory') 
    service_args = JSON.parse(worker_args['args'])
    [service_args['shop_id'], service_args['bundle_id'], service_args['inventory_item_id'], service_args['location_id'] ]

  elsif worker_args['service'].eql?('Products') 
    unique_jobs = JSON.parse(worker_args['args'])
    variant = unique_jobs['webhook']['variants'].map {|variant| [variant["id"], variant["product_id"], variant["title"], variant["sku"], variant["price"]]}  
    [unique_jobs['shop_domain'], unique_jobs['webhook']['product_id'], unique_jobs['webhook']['product_title'], variant[0]].flatten
  else
    return args
  end
end
  def perform(options)
    sleep 10.second
    options["service"].constantize.new(
      MultiJson.load(options["args"]).deep_symbolize_keys
    ).call
  end

I added service-based conditions. But when i run sidekiq job so all jobs process. Also checked with sleep time.
Can anyone please check configuration is correct or if I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant