• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how efficient are threadds for sending mails??

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm writing a mailer daemon. My program will be querying a one column table for message ids. if there is a message id in that table then a master message table will be queried for that message id. From this master table we'll get to_id, from_id and body part of message. and By using JAVA mail API i'll send mail on to_id. and once mail is sent the record from one column table will be deleted.
Somebody gave me suggetion to use treading for this application, so that the performance will be improved. According to him my program will start 5 threads at a time and will do the job what i've explained above and it'll improve performance by 5 times. I'm not convinced with this concept. can anybody comment on this or suggest scallable solution???
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
99% of your time will be spent talking to the mail server. The mail server, in turn, spends all of that time doing I/O. Because of this, your mail throughput will be roughly proportional to the number of connections you open to the server, i.e. to the number of threads. Your colleague is right.
One remark, by the way: have you considered using JMS for this? What you describe looks exactly like the problem JMS was created to solve. Using JMS will also instantly solve all threading issues for you; to increase message throughput, just start up more message consumers.
- Peter
 
Amit Rogye
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Peter den Haan:
99% of your time will be spent talking to the mail server. The mail server, in turn, spends all of that time doing I/O. Because of this, your mail throughput will be roughly proportional to the number of connections you open to the server, i.e. to the number of threads. Your colleague is right.
One remark, by the way: have you considered using JMS for this? What you describe looks exactly like the problem JMS was created to solve. Using JMS will also instantly solve all threading issues for you; to increase message throughput, just start up more message consumers.
- Peter



Thanks for Reply. Can you tell how can i use JMS??? any sample or article will be helpful
/Amit
[ April 10, 2002: Message edited by: Amit Rogye ]
 
Peter den Haan
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sigh. Actually I have just developed a JMS-backed email queue. Unfortunately I'm not free to give you the code or the design detail.
In JMS, you can queue (among other things) any Serializable object. So all you have to do is queue an object that knows how to populate the JavaMail Message object, or maybe an object that carries the various ids you mentioned and that can be used to generate the e-mail.
It's all pretty straightforward and you don't need to use any JMS wizardry; if you rummage around on the net you're bound to find simple examples of queuing and dequeuing messages. It gives you ease of use, thread safety, and (if you use JMS's transactional capabilities) a guarantee that the e-mail will be sent out whatever happens.
You can use the JMS implementation built into the application server if your server has one, or an add-on implementation. OpenJMS is a decent open source implementation backed by a relational database.
- Peter
[ April 10, 2002: Message edited by: Peter den Haan ]
 
There's a way to do it better - find it. -Edison. A better tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic