Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Javax Mail Transport.send(message) is blocking!

 
Bartender
Posts: 1891
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In one of my classes called from a DAO class in Hibernate, I send an email using the standard Javax mail.

The problem is that the class code is blocking (waiting, synchronously) on the 'Transport.send(message)' and causing delays -- the browser page doesn't fully refresh until the email is sent.

Would a solution to this problem be to create another thread from that DAO class and send the email using that new thread or is there some async way to use the 'Transport.send(message)' that I haven't seen?

Thanks for any advice or suggestions!

- Mike
 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

is there some async way to use the 'Transport.send(message)'


None that I know of in JavaMail, but I have used JMS - the e-mail is queued to be sent, and a MDB sends the mail asynchronously. A separate thread is a solution, too, of course.
 
Mike London
Bartender
Posts: 1891
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps if I made the call for sending the email from the browser, it would handle the multitasking better than making the call from a java program.

I'll try that.

Thanks.

-- Mike
 
please buy this thing and then I get a fat cut of the action:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic