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
Exception handling with DelayedJob #35
Comments
Hey, This is all about context. If you use DelayedJob to deliver your emails in the background, any exceptions risen will appear in the context of a running worker. Whereas This has nothing to do with the gem, it’s a pure Ruby and your architectural choices. I don’t use DelayedJob too much, but I don’t see anything special about it in this case. From what I know this should work fine: class User < ActiveRecord::Base
def deliver_welcome_email
UserMailer.welcome_email(self).deliver
rescue Postmark::InvalidMessageError => e
# ...
end
end
u = User.first
u.delay.deliver_welcome_email If you send a lot of different emails, you might want to delegate error handling to a separate class (this would also be handy if you decide to implement a bounce hook), but again, this is all up to you. Please let me know if I miss something or you need any further guidance here. |
I have no idea why this is happening but this doesnt appear to work. While the email is being sent, we are getting tons of errors such as this:
The code is pretty trivial:
and we're calling it from a private method after_create:
Like I said, the email actually goes through and is delivered, and DJ eventually removes the message from the queue, but we still get these errors. Not sure where to go from here. |
@noctivityinc this looks like a problem in DJ to me. A similar problem has occurred before (see collectiveidea/delayed_job#323). Please make sure you’re currently running a version that includes collectiveidea/delayed_job@0234444. If you can’t figure out, feel free to mail us at support@postmarkapp.com or create a separate issue describing how we can reproduce the problem. |
I've been reviewing issue #19 to clear up the best way to handle postmark exceptions. I thought I'd found the answer I was looking for but it seems i'm only halfway there. As @dgilperez points out the suggested code does work but doesn't seem to work with in conjunction with delayed job.
I believe this will probably be something we need to address with delayed job but thought I'd see if the postmark team had any thoughts or fixes for the issue before I got to far down the rabbit hole.
The following is working for me without DelayedJob in the workflow.
The text was updated successfully, but these errors were encountered: