Comments (4)
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.
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.
@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.
Closing, please reopen after testing with recent Sneakers version and verifying problem continues.
from sneakers.
Related Issues (20)
- sneakers.io expired? HOT 2
- What is the plan for 2.13.0? HOT 16
- Getting this error while trying to drive watir within my workers HOT 2
- Sneaker close connection with Rabbit after hours inactivity, HOT 5
- If there is a `@` in RabbitMQ password, you may have an `Unexpected error bad URI`. HOT 2
- Is still actively maintained? HOT 7
- Messages not sent from rabbitmq to sneakers
- Is there some potential issues if setting single worker but multi-thread in prd env? HOT 2
- Infinity restart when errors happens inside of hooks
- Stops "ack!"ing after 10 messages HOT 2
- Channels not recovering after server restart HOT 4
- Ruby 3.2.0 File#exists? HOT 1
- Memory leak HOT 2
- Consumer thread interrupt HOT 4
- Rails 7.0.4.2 - NoMethodError: undefined method `autoloader' for #<Rails::Application::Configuration... HOT 2
- too many accepting and closing AMQP connections in the rabbitmq server logs HOT 1
- Dead letter queue consumption issue HOT 2
- How to Inject code into worker initialization?
- Documentation not very clear on how to handle DB connections when using the gem in a Rails application HOT 2
- Channel shared between threads for MaxRetry handler
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sneakers.