App Engine Python Modules and inbound mail service
Asked Answered
G

2

7

I am using App Engine Modules in my python project. (https://developers.google.com/appengine/docs/python/modules/#Python_Background_threads)

I am also receiving email in m project: https://developers.google.com/appengine/docs/python/mail/receivingmail

I want to direct the emails to my worker module and not the default module. To that end my worker.yaml has the following settings

worker.yaml

    api_version: 1
    application: integrate
    module: worker
    version: 1-0-0
    runtime: python27
    threadsafe: true

    inbound_services:
    - mail

    builtins:
    - deferred: on

    handlers:

    - url: /admin/.+
      script: src.worker.main.app
      login: admin

    - url: /_ah/mail/.+
      script: src.worker.main.app
      login: admin

    - url: /.*
      script: src.worker.main.app

app.yaml

    api_version: 1
    application: integrate
    version: 1-0-0
    runtime: python27
    threadsafe: true

    builtins:
    - deferred: on

    handlers:

    - url: /admin/.+
      script: src.default.main.app
      login: admin

    - url: /.*
      script: src.default.main.app

I even tried adding a dispatch.yaml

    application: integrate

    dispatch:
    - url: "*/_ah/mail/.+"
      module: worker

But no matter what I do the emails which reach my app are handled by the default module. Any idea what I am missing here? I see the emails coming in but no matter what I do they only go to the default module.

Gdynia answered 2/10, 2013 at 17:24 Comment(7)
Does this happen on local and on live versions?Arad
Thanks for your comment. It works locally but not live. Once live it doesn't get redirected by the dispatch.yaml.Gdynia
By the way this is my exact issue. The same thing is true with the channel api. The inbound services don't seem to respect the dispatch.yaml in production.Gdynia
Sounds like a bug to me. I haven't tried your code, but perhaps report it code.google.com/p/googleappengine/issues/listArad
code.google.com/p/googleappengine/issues/detail?id=10071Gdynia
you get any feedback from anyone about this?Arad
No. I have had no feedback. I'm working around this issue with a mail handler in the default module.Gdynia
C
4

Inbound services could be used only within default module and that is expected behavior. The fact that it works for you locally in devserver is a bug, actually.

Carmelitacarmelite answered 19/3, 2014 at 13:35 Comment(1)
Yes this is true.This didn't use to be documented. I should added this when it was.Gdynia
E
-1

Just some additional info for the answer which may help folks in a similar situation.

I noticed in the DevServer log:

"Skipping dispatch.yaml rules because /_ah/mail/[EMAIL_ADDRESS_FOR_APP] is not a dispatchable path."

This is no doubt due to local config, however.

Regardless, the workaround I have now using Tasks is:

  • Dispatch or directly handle Inbound Mail in the default module
  • Provide a script handler that creates a Task, taking the relevant MailMessage data as the payload
  • Set the TaskQueue in queue.yaml to target the module you wish to process the payload data, e.g. a 'worker' module
Ellary answered 9/8, 2014 at 12:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.