Click on Javadoc link to open Javadoc documentation.
Package
org.gridgain.grid.spi.communication.mail ![]()
Description
GridMailCommunicationSpi ![]()
![]()
When working with email communication, make sure that maximum send/receive limit set by mail server is not exceeded. Sometimes it is better to configure your own mail server to avoid such limitations.
Note, that due to its nature mail communication is much slower than other implementations of communication SPI's and measures communication delays in minutes rather than in seconds. This means that execution of some tasks can fail more often than with other SPI's due to nodes leaving grid topology. In most cases user should implement a custom GridFailoverResolver ![]()
![]()
![]()
Configuration
The following configuration parameters can be used to configure GridMailCommuncationSpi
| Setter Method | Description | Optional | Default |
|---|---|---|---|
| setOutHost(String) |
Outgoing host name for sending emails (usually either SMTP or IMAP). | No | — |
| setInHost(String) |
Incoming host name for receiving emails (usually either POP or IMAP). | No | — |
| setFromAddress(String) |
'From' address for all email messages. It is added as ATTR_EMAIL_ADDR node attribute so it can be accessed on remote nodes. This address is used by other nodes to send email to this node. |
No | — |
| setOutConnectionType(GridMailCommunicationType) |
Type of outgoing mail connection which should be one of the following: | Yes | GridMailCommunicationType.NONE |
| setOutPort(int) |
Port number for outgoing mail. | Yes | Port 25 |
| setOutUsername(String) |
Username for outgoing mail authentication. If provided, then password should also be provided. | Yes | null, which means that no authentication will be used. |
| setOutPassword(String) |
Password for outgoing mail authentication. If provided, then username should also be provided. | Yes | null, which means that no authentication will be used. |
| setOutCustomProperties(Properties) |
Any custom properties required for outgoing connection. | Yes | null |
| setOutProtocol(GridMailCommunicationOutProtocol) |
Outgoing mail protocol. Should be one of the following: | Yes | GridMailCommunicationOutProtocol.SMTP |
| setInConnectionType(GridMailCommunicationType) |
Type of incoming mail connection which should be one of the following: | Yes | GridMailCommunicationType.NONE |
| setInPort(int) |
Port number for incoming mail. | Yes | Port 110 |
| setInUsername(String) |
Username for incoming mail authentication. If provided, then password should also be provided. | Yes | null, which means that no authentication will be used. |
| setInPassword(String) |
Password for incoming mail authentication. If provided, then username should also be provided. | Yes | null, which means that no authentication will be used. |
| setInCustomProperties(Properties) |
Any custom properties required for receiving connection. | Yes | null |
| setInProtocol(GridMailCommunicationInProtocol) |
Incoming mail protocol. Should be one of the following: | Yes | GridMailCommunicationInProtocol.POP3 |
| setSubject(String) |
Email message subject. | Yes | grid.email.comm.msg |
| setFolderName(String) |
Name of email folder on mail server. | Yes | Inbox |
| setStoreFileName(String) |
Locally stored full file name for all read messages. Can be either full path or a path relative to ${GRIDGAIN_HOME} | Yes | grid-email-comm-msgs.dat |
| setReadBatchSize(int) |
Number of messages fetched from mail server at a time. | Yes | 100 |
| setReceiverDelay(long) |
Interval in milliseconds between checking for new messages. | Yes | 10000 ms |
| setLeaveMessagesOnServer(long) |
Incoming messages life-time on mail server in milliseconds. | Yes | 86400000 ms |
Examples
GridMailCommunicationSpi ![]()
GridMailCommuncationSpi commSpi = new GridMailCommuncationSpi(); // Inbox configuration. commSpi.setInHost("pop.google.com"); // Outbox configuration. commSpi.setOutHost("smtp.google.com"); // Incoming/outgoing e-mail address configuration. commSpi.setFromAddress("grid@google.com"); GridConfigurationAdapter cfg = new GridConfigurationAdapter(); // Override default communication SPI. cfg.setCommunicationSpi(commSpi); // Start grid. GridFactory.start(cfg);
or from Spring configuration file
<bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true"> ... <property name="communicationSpi"> <bean class="org.gridgain.grid.spi.communication.mail.GridMailCommunicationSpi"> <property name="outHost" value="smtp.google.com"/> <property name="inHost" value="pop.google.com"/> <property name="fromAddress" value="grid@google.com"/> </bean> </property> ... </bean>

For more information about using Spring framework for configuration click here.
