This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Trying to implement a mail queue in JavaMail using ExecutorService  RSS feed

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to implement a Mail Queue type affair in JavaMail using the ExecutorService to free up resources from the main app whilst the Mailer is cycling through the list of recipients as I'm working on a scheduling system which deals with groups of people by emailing each person separately.
So far I've got:

The error that I'm getting is that pool.execute(new sendMail(msg)); is empty but the msg is being created. Originally my class sendMail looked like:

which sent a mail with four names in the TO field (I'm trying to send one email to each recipient so that no group member can define the membership emails).

I don't doubt that there is something that I have not understood, but I'd appreciate some pointers as to how to achieve the Queuing effect.
 
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Iain: The error that I'm getting is that pool.execute(new sendMail(msg)); is empty but the msg is being created.



I am not sure I am following this statement.
What do you intend by "pool.execute(new sendMail(msg)); is empty"?
Is it so that you do not add any tasks to the executor but still it is getting executed?
I strongly believe that such a thing is not possible. Either some other part of your program is sending an e-mail that you do not expect or there is some confusion over the emptiness of the executor.

BTW, I do not see a code that initializes the executor. Is that something you are missing.
Also, If you are getting an error please post the same.
 
Iain Emsley
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nitesh, thanks, I'd missed out calling the newCachedThreadPool() although the threading has changed the programme's behaviour a little from sending an email to each address to lumping all the addresses together but I suspect a rewrite will sort that out.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!