This week's book giveaway is in the Design forum.
We're giving away four copies of Head First Software Architecture: A Learner's Guide to Architectural Thinking and have Raju Gandhi, Mark Richards, Neal Ford on-line!
See this thread for details.
  • 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

JavaMail Connections

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
This is my first shot at the JavaMail API. As i understand, one can register the host details in JNDI and can access the same to send emails. I am thinking of the Mail Service Providers as Driver Softwares that know Mail Protocols and have the required knowledge to connect to a Mail Server. I guess i can see an analogy between this and JDBC/LDAP connections. I understand that we may pool JDBC/LDAP Connections. My questions are...

1)When we get a Mail Session from the JNDI, are we creating a connection to the mail server? Or, is this any different from the JDBC/LDAP Connections?

2)Is it possible to pool connections to the Mail Server? (Does it even make sense? )

I browsed thru couple of books and also looked at internet. I didnt find anything so far that says "Pool Mail connections".

Thanks for your help.

Thanks
Karthik
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by karthik vijayarajan:

1)When we get a Mail Session from the JNDI, are we creating a connection to the mail server? Or, is this any different from the JDBC/LDAP Connections?



I don't think so. If you look at the Session API doc the Session object seems more about settings than connectivity:

It collects together properties and defaults used by the mail API's. A single default session can be shared by multiple applications on the desktop. Unshared sessions can also be created.


I believe it is some subclass of Transport provided by your mail implementation that actually does the work of connecting to the server.

Originally posted by karthik vijayarajan:

2)Is it possible to pool connections to the Mail Server? (Does it even make sense? )


I'd say yes, but it would cost more than it is worth.
The reason we pool database connections is because they are non-trivial to create and they are designed to be long-lived, with the client and server exchanging large amounts of information with detailed security and resource management. SMTP, on the other hand, has little overhead.
If it were smart to pool SMTP connections, there'd probably be a class in the API like DataSource.
 
Karthik Vijayarajan
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your thoughts.
Your inputs were very helpful. I guess i could have done better with the API . I missed the Transport class.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic