JavaMail Store connection: connect on demand or keep in touch?

What makes sense for JavaMail?

  • Create a Store connection for each request on the email server, and then close it immediately after the task completes.

  • Open a connection to the Store and only reconnect if the connection is closed by the server or the local application is completed.

Although (1) can lead to multiple calls to connect () and close () in a row, (2) can block resources, although this would not really be necessary (but IMAP / POP3 calls would be quick, since without additional. Connect () required).

+4
source share
1 answer

Connecting on demand is better if you do not have the requirement to often poll the server from a single stream.

+4
source

Source: https://habr.com/ru/post/1334822/


All Articles