Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Iain Emsley
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.
 
Nitesh Kant
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!