According to this part of the documentation, it would seem that
setting up an email-sending task-queue is impossible. After all,
sending someone the same email thousands of times would be disastrous.
Yet the documentation also gives email sending as an example use of
the Task Queue.
This seems to be contradictory. How can I create a Task Queue for
sending email without running into problems of idempotence?
Thanks for your help.
Code defensively - do all the work (that might fail) up front in your
task and send the email as a last step. The only problem would be
something going wrong in the email send process itself (or the task
service wrapup). Could this theoretically result in an extra email to
the user? Sure. Will it result in 1,000 emails to the user? It
seems pretty unlikely.
Jeff
> --
> You received this message because you are subscribed to the Google Groups "Google App Engine" group.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
>
>
I guess I'll just have to hope that everything goes okay, and write
lots of try/except clauses in my code to make sure the "little things"
don't mess stuff up.
Thanks anyways,
> > google-appengi...@googlegroups.com<google-appengine%2Bunsubscrib e...@googlegroups.com>
Try to send your emails as a final step. If you want to be super
extra careful, create another task that does nothing but call the
email send service. If you can use transactions, enlist this task
creation into the transaction.
Jeff
> To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
At least you off load your work from the primary transaction.
Remember email isn't really a reliable service, and even if you do
mark it as sent it may never reach the recipient.
Pushing the send email workload and recording if you sent it into a
task should not really cost you to much
in end user response times/latency.
As someone else put it email is not transactional in any sense. Its
very much a
"throw it over the fence and hope it gets there in the next few days"
T
"DeadlineExceededError: The API call mail.Send() took too long to
respond and was cancelled."
error. However, the same email was sent 3 times, successfully.
That's bad enough, but I would hate to have it send a few thousand
times!
Could this have anything to do with the new queue limit of 50/second?
Should a mail queue be set to a smaller number?
queue:
- name: mail-queue
rate: 50/s
bucket_size: 10
So the question is, how can I put an email in the taskqueue, and have
the task not re-executed if the mail.send() takes too long?
One way to work around this is to put the email sending in a try/
except clause so that if it does get an error it would not still
return okay. And, at the same time, you can do whatever you want to
process the error.
try:
mail.send_mail( ...)
except Exception, e:
logging.error( str(e) )
return