Git Product home page Git Product logo

Comments (4)

jondot avatar jondot commented on June 20, 2024

Hi,
Can you show some of your work method so I can see how the reject/ack is used? you can use some pseudo-code and not the real code.

thanks

from sneakers.

magnum avatar magnum commented on June 20, 2024

thank you @jondot here's the code of the worker

require 'sneakers'

Sneakers.configure :timeout_job_after => 1800

class QueueWorkerBackoffice
  include Sneakers::Worker
  from_queue(
    'backoffice',
    :durable => true,
    :ack => false,
    :threads => 5,
    :prefetch => 5
  )


  def work(msg)

    puts "WORKING..."

    begin
      data = Lovethesign::Queue.unserialize(msg)

      # logging queue_message to db
      queue_message = QueueMessage.create({
        message_class: data[:class],
        message_method: data[:method],
        params: data[:params],
        url: data[:url],
        queue: data[:queue],
        site: Site.by_code(data[:site]),
      })
      BackofficeMailer.queue_message_info(queue_message).deliver # sending email



      case data[:class]
      when 'order' # order
        puts "ORDER #{data[:params][:order][:order_id]} found in queue"
        if data[:method] == "order"
          data[:params][:order][:products].each do |p|
            adjust_value = -p[:qty].to_i
            message = "updated from order #{data[:params][:order][:order_id]}"
            Stock.adjust_by_value! p[:model], adjust_value, nil, message
            puts "updating stock of #{p[:model]} with #{adjust_value}"
            Stock.notify_sites! p[:model]
            puts "notifying sites for #{p[:model]} stock change to #{Stock.value_per_sku(p[:model])}"
            $backoffice.log "stock updating #{p[:model]}, adjust_value: #{adjust_value}"
          end
        end
      end

      ack!


    rescue StandardError => e
      error_output = "#{e.message}\n#{e.backtrace.join("\n")}"
      BackofficeMailer.generic_message("error in QueueWorkerBackoffice", error_output).deliver # sending email

      reject!

      raise e
    end

  end

end

ack problem apart, I found often this problems

  • sometimes it goes timeout, simply outputting this in the log file
2014-08-27T07:59:00Z p-15485 t-ow7tmadlw ERROR: could not obtain a database connection within 5.000 seconds (waited 5.000 seconds)
  • sometimes it goes timeout, simply outputting this in the log file
2014-08-27T17:39:26Z p-4933 t-otj62rojk ERROR: timeout

from sneakers.

jondot avatar jondot commented on June 20, 2024

@magnum I think your second error is due to the fact that the database connections can't hold the high level of parallelism that sneakers introduces. You should increase connections in the connection pool

from sneakers.

jondot avatar jondot commented on June 20, 2024

Closing, please reopen after testing with recent Sneakers version and verifying problem continues.

from sneakers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.