You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add section for exception handling
* used rescue_from instead of around_perform
* Update README.md to raise exception after rescue
---------
Co-authored-by: Rosa Gutierrez <[email protected]>
Note: `on_thread_error`is intended for errors in the thread that is executing the job and not for errors encountered in the job. For errors in the job itself, [refer here](#exceptions)
229
+
230
+
- `connects_to`: a custom database configuration that will be used in the abstract `SolidQueue::Record` Active Record model. This is required to use a different database than the main app. For example:
231
+
=======
226
232
**This is not used for errors raised within a job execution**. Errors happening in jobs are handled by Active Job's `retry_on` or `discard_on`, and ultimately will result in [failed jobs](#failed-jobs-and-retries). This is for errors happening within Solid Queue itself.
233
+
>>>>>>> main
227
234
228
235
- `use_skip_locked`: whether to use `FOR UPDATE SKIP LOCKED` when performing locking reads. This will be automatically detected in the future, and for now, you'd only need to set this to `false` if your database doesn't support it. For MySQL, that'd be versions < 8, and for PostgreSQL, versions < 9.5. If you use SQLite, this has no effect, as writes are sequential.
229
236
- `process_heartbeat_interval`: the heartbeat interval that all processes will follow—defaults to 60 seconds.
@@ -308,7 +315,40 @@ failed_execution.retry # This will re-enqueue the job as if it was enqueued for
308
315
failed_execution.discard # This will delete the job from the system
309
316
```
310
317
318
+
<<<<<<< add-documentation-for-handling-exceptions
319
+
We're planning to release a dashboard called _Mission Control_, where, among other things, you'll be able to examine and retry/discard failed jobs, one by one, or in bulk.
320
+
321
+
### Exceptions
322
+
323
+
For errors encountered in the job, you could try to hook into [Active Job](https://guides.rubyonrails.org/active_job_basics.html#exceptions) and report the errors to your exception monitoring service.
324
+
325
+
Let's see an example implementation to handle exceptions.
326
+
327
+
```ruby
328
+
# application_job.rb
329
+
class ApplicationJob < ActiveJob::Base
330
+
rescue_from(Exception) do |exception|
331
+
Rails.error.report(exception)
332
+
raise exception
333
+
end
334
+
end
335
+
```
336
+
337
+
Note that, you will have to duplicate the above logic on `ActionMailer::MailDeliveryJob` too. That is because `ActionMailer` doesn't inherit from `ApplicationJob` but instead uses `ActionMailer::MailDeliveryJob` which inherits from `ActiveJob::Base`.
338
+
339
+
```ruby
340
+
# application_mailer.rb
341
+
342
+
class ApplicationMailer < ActionMailer::Base
343
+
ActionMailer::MailDeliveryJob.rescue_from(Exception) do |exception|
344
+
Rails.error.report(exception)
345
+
raise exception
346
+
end
347
+
end
348
+
```
349
+
=======
311
350
However, we recommend taking a look at [mission_control-jobs](https://github.com/rails/mission_control-jobs), a dashboard where, among other things, you can examine and retry/discard failed jobs.
0 commit comments