Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


EJB Messaging, Part I: JMS and JavaMail-4 : Page 4




Application Security Testing: An Integral Part of DevOps

EJBs and JavaMail Messaging
Obtaining a JavaMail session is considerably easier than obtaining a JMS session. You obtain a JavaMail session reference directly via a JNDI lookup; no additional method calls are required.

Assuming the following deployment descriptor settings:

   <description> This is a textual description 
of the resource.</description> <res-ref-name>mail/Email</res-ref-name> <res-type>javax.mail.Session</res-type> <res-auth>Container</res-auth> </resource-ref>

The code required to obtain a JavaMail session is as follows:

// Obtain the initial JNDI context
Context context = new InitialContext();

// JNDI lookup to obtain resource manager connection 
factory reference javax.mail.Session session = (javax.mail.Session) context.lookup("java:comp/env/mail/Email");

At this point you have a reference to a javax.jms.Session object and you are free to build QueueSender and QueueReceiver objects to be used in a point-to-point message exchange with other JMS clients.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date