6 Replies Latest reply on Sep 28, 2008 11:11 PM by danielc.roth

    Send mail asynchronous

    bashan

      Hi,


      Is there a way sending mail asynchronously in Seam (I am sending mail using Seam components and render method)?
      Will there be any problem losing the context (for example, if I put the mail data in Event context) while sending mail asynchronously?


      Thanks,
      Guy.

        • 1. Re: Send mail asynchronous

          Look in the mail example that comes with Seam. There is an async example.

          • 2. Re: Send mail asynchronous
            tony.herstell1

            Asynch Main and Mail in general has had a few niggles.
            Ensure you use the latest code from the main branch as this is supposed to have fixed a number of things.

            • 3. Re: Send mail asynchronous
              bashan

              Hi,
              I just want to know if I should be concerned if mail is sent in async mode to the scopes. For example that EVENT scope won't be available while mail is being sent...

              • 4. Re: Send mail asynchronous
                accless

                In general, the only scopes that are available in any asynchronous call are:


                1) buisness process
                2) Application-scope


                so u have to give all the data u need as a parameter of the async-Method or store the datas and retrieve them later in your async-Method


                greetings

                • 5. Re: Send mail asynchronous
                  bashan

                  Hi Rene,


                  I am trying to understand if this code taken from Seam examples will work, because I will have something pretty similar (this code puts data in the event context, I am trying to understand if the event context will keep existing even request ended):


                  @Name("asynchronousMailProcessor")
                  @AutoCreate
                  public class AsynchronousMailProcessor
                  {
                     @Asynchronous
                     public void scheduleSend(@Duration long delay, Person person) {
                        try {
                           Contexts.getEventContext().set("person", person);
                           Renderer.instance().render("/simple.xhtml");
                        } catch (Exception e) {
                           e.printStackTrace();
                        }
                     }
                  }



                  Thanks,
                  Guy.

                  • 6. Re: Send mail asynchronous

                    It's not the same Event context. The call to scheduleSend will occur in one event context, which end when the response has been sent to the browser.


                    The actual execution of scheduleSend, which may occur long time into the future, will have  another Event context.