• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Trying to implement a mail queue in JavaMail using ExecutorService

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Won't you please? Please won't you be my neighbor? - Fred Rogers. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic