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

Creating JavaMail session pool

 
Ranch Hand
Posts: 129
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to create mail session pool using java mail. I am using tomcat 5.5.
I tried several code about how to configure but nothing worked.
When I use it without JNDI entry means I created a new session every time I want to send mail
it worked fine.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there some reason a javax.mail.Session cant just be re-used? The JavaDocs suggest one session can be used by multiple applications.

Bill
 
ramnna jain
Ranch Hand
Posts: 129
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you William. Actually I am developing a web application using Tomcat 5.5.
And I come to know that the session object creation is an overhead to the server as in the case of database connection.
Specially when I expect thousands of users want mail session very frequently I must implement some mail session pool.

Please correct me if I am wrong...
 
Marshal
Posts: 27996
94
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That didn't sound like a reason why sessions can't be reused.
 
ramnna jain
Ranch Hand
Posts: 129
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes session can be reused but if there are thousands of concurrent requests for one mail session object,
I doubt the situation may go out of control. That is why I am thinking to create a session pool.
Could you please tell me if it would create a critical situation when thousands of users seeking one and only session object!
Please guide me to understand. Thank you.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

if there are thousands of concurrent requests for one mail session object,



I have not examined the source code, but I get the impression from the JavaDocs that a session just serves as a "data object" that organizes all of the parameters needed in one place. If an object does not contain any variables that are altered by users, there is no reason you can't have thousands of "concurrent" users. Basically the same principle that lets one servlet instance handle any number of requests "simultaneously."

If you are worried about it, get the source code and look for variables that get modified by users.

Please let us know if you find any.

Bill
 
ramnna jain
Ranch Hand
Posts: 129
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting more confused... I think I must ask the question differently.. so that I can understand it better...

As in the case of database connections: in our tomcat application there are several servlets and according the user requests there are many threads running and seeking database connection to fetch the desired result from the database. Because there are thousands of threads seeking database connection. We create database connection pool so that when one such connection is being utilized the other connection which is free to serve can be used. Here in this case one database connection is insufficient to handle the several concurrent requests at a time.

Similarly if we have one mail session object to serve then would it server to all threads out of the servlets, requesting to get the session to send mail!

I am thankful to your help and time.
 
Paul Clapham
Marshal
Posts: 27996
94
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you see connection pools routinely being used, but mail session pools not being used, in a product which is used by probably hundreds of thousands of people, doesn't it lead you to believe that mail session pools aren't necessary?

You don't seem to be asking because you're having a problem. So I would suggest that you don't have a problem.
 
ramnna jain
Ranch Hand
Posts: 129
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you William for patiently replying and answering to understand the subject.

Paul thank you! I understood the mail session pools are not necessary. Only one mail session object is sufficient even when my application is having multiples of thousands of users intensively utilizing the session object.

Thank you.
 
Paul Clapham
Marshal
Posts: 27996
94
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, yours might be the one application in a million for which your usage of mail sessions is so heavy that you need to do something special. But I rather doubt it. Presumably you aren't having problems with these thousands of users right now?
 
ramnna jain
Ranch Hand
Posts: 129
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul thank you! Thank you very much.... for your suggestion and dignosing capability... thank you...
 
Blueberry pie is best when it is firm and you can hold in your hand. Smell it. And smell this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic