Java Mail API: Transforming Mail into Data Carriers - Mails As Data Carriers: A Practical Approach
(Page 3 of 5 )
When data transfer is the issue (in the context of J2EE), there are three possible approaches:
- Use Message Driven Beans or JMS.
- Use XML over HTTP.
- Generate a document in a predefined format (XML/SGML) and send it through mailing.
Usually the first two approaches have been followed until now. The third approach was in a way scoffed at because third party mailing APIs had to be used. But with the advent of the Java Mail API, the third approach is becoming more viable due to the following reasons:
- The MDB or JMS needs a full fledged application server, which means a higher requirement for system resources.
- The communication, in the case of MDB, takes place in binary format (unless it is specifically programmed to use base 64). That brings firewalls into the picture.
- The XML over HTTP approach requires a separate server (e.g.: SOAP server) to perform the required processing, which again means a high end system is required.
Now that the problems with the first two approaches have been clarified, let's see how Java Mail helps in overcoming them. The approach with Java Mail is simple. First, generate the XML document from the data. Second, transfer the data using Java Mail to the required host. Finally, extract the data from the XML attachment and extract the data from the XML document.
In this way, no matter the size of the data, it can be transferred. Here the Mail API doesn’t put any restriction on the size of the attachment. The restriction, if any, comes from the limitations enforced by the Mail server, and that is configurable.
Next: Sending >>
More Java Articles
More By A.P.Rajshekhar