sharing message object between web applications
Posted
by jezhilvalan
on Stack Overflow
See other posts from Stack Overflow
or by jezhilvalan
Published on 2009-06-30T08:00:02Z
Indexed on
2010/04/02
6:03 UTC
Read the original article
Hit count: 298
I need to share java mail message objects between two web applications(A and B).
WebApplication A obtains the message and write it to the outputStream
for(int i=0;i<messagesArr.length;i++){
uid = pop3FolderObj.getUID(messagesArr[i]);
//storing messages with uid names inorder to maintain uniqueness
File f = new File("F:/PersistedMessagesFolder" + uid);
FileOutputStream fos = new FileOutputStream(f);
messagesArr[i].writeTo(fos);
fos.flush();
fos.close();
}
Is FileOutputStream the best output stream for persisting message objects? Is it possible to use ObjectOutputStream for message object persistence?
WebApplication B reads the message object via InputStream
FileInputStream fis = new FileInputStream("F:/MessagesPersistedFolder"+uid);
MimeMessage mm = new MimeMessage(sessionObj,fis);
What if the mail message object which is already written via WebApplication A is not a MimeMessage? How can I read non-mime messages using input stream?
MimeMessage constructor mandates sessionObj as the first parameter? How can I obtain this sessionObj in WebApplicationB? Do I have to again establish store connection with the same emailid,emailpassword,popserver and port(already used in WebApplication A) with the email server inorder to obtain this session object? Even if obtained, will this session object remains the same as that of the session object which is priorly obtained in WebApplicationA?
Since I am using uids to name Message objects (inorder to maintain uniqueness of file names) how can I share these uids between WebApplication A and WebApplication B? WebApplication B needs the uid inorder to access the specific file which is present in "F:/MessagesPersistedFolder"
Please help me in resolving the aforeseen issues.
© Stack Overflow or respective owner