Dashboard > GridGain User Guide > Table Of Contents > GridGain Book > Communication SPI > GridMailCommuncationSpi
GridMailCommuncationSpi
Added by usr1, last edited by morpheus on Jul 31, 2007  (view change)
Labels: 
(None)


Click on Javadoc link to open Javadoc documentation.

Package

org.gridgain.grid.spi.communication.mail Javadoc

Description

GridMailCommunicationSpi Javadoc is email implementation of GridCommunicationSpi Javadoc . Email communication is provided for cases where nodes from different networks (even different countries) need to participate in grid task execution together as it usually can penetrate through any firewall. It supports SMTP/POP and IMAP email access protocols and can be used to connect to any public or private email server out there.

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 Javadoc (see GridTask.getFailoverResolver() Javadoc ), which should check if a node is still alive using Grid.pingNode(UUID) Javadoc method. Use this SPI whenever it is acceptable to react to node topology changes with substantial delay.

Configuration

The following configuration parameters can be used to configure GridMailCommuncationSpi

Setter Method Description Optional Default
setOutHost(String) Javadoc
Outgoing host name for sending emails (usually either SMTP or IMAP). No
setInHost(String) Javadoc
Incoming host name for receiving emails (usually either POP or IMAP). No
setFromAddress(String) Javadoc
'From' address for all email messages. It is added as ATTR_EMAIL_ADDR Javadoc
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) Javadoc
Type of outgoing mail connection which should be one of the following:
  • GridMailCommunicationType.NONE Javadoc
  • GridMailCommunicationType.SSL Javadoc
  • GridMailCommunicationType.STARTTLS Javadoc
Yes GridMailCommunicationType.NONE Javadoc
setOutPort(int) Javadoc
Port number for outgoing mail. Yes Port 25
setOutUsername(String) Javadoc
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) Javadoc
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) Javadoc
Any custom properties required for outgoing connection. Yes null
setOutProtocol(GridMailCommunicationOutProtocol) Javadoc
Outgoing mail protocol. Should be one of the following:
  • GridMailCommunicationOutProtocol.SMTP Javadoc
  • GridMailCommunicationOutProtocol.SMTPS Javadoc
Yes GridMailCommunicationOutProtocol.SMTP Javadoc
setInConnectionType(GridMailCommunicationType) Javadoc
Type of incoming mail connection which should be one of the following:
  • GridMailCommunicationType.NONE Javadoc
  • GridMailCommunicationType.SSL Javadoc
  • GridMailCommunicationType.STARTTLS Javadoc
Yes GridMailCommunicationType.NONE Javadoc
setInPort(int) Javadoc
Port number for incoming mail. Yes Port 110
setInUsername(String) Javadoc
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) Javadoc
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) Javadoc
Any custom properties required for receiving connection. Yes null
setInProtocol(GridMailCommunicationInProtocol) Javadoc
Incoming mail protocol. Should be one of the following:
  • GridMailCommunicationInProtocol.POP3 Javadoc
  • GridMailCommunicationInProtocol.POP3S Javadoc
  • GridMailCommunicationInProtocol.IMAP Javadoc
  • GridMailCommunicationInProtocol.IMAPS Javadoc
Yes GridMailCommunicationInProtocol.POP3 Javadoc
setSubject(String) Javadoc
Email message subject. Yes grid.email.comm.msg
setFolderName(String) Javadoc
Name of email folder on mail server. Yes Inbox
setStoreFileName(String) Javadoc
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) Javadoc
Number of messages fetched from mail server at a time. Yes 100
setReceiverDelay(long) Javadoc
Interval in milliseconds between checking for new messages. Yes 10000 ms
setLeaveMessagesOnServer(long) Javadoc
Incoming messages life-time on mail server in milliseconds. Yes 86400000 ms

Examples

GridMailCommunicationSpi Javadoc needs to be explicitely configured

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.

Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.10 Build:#528 Nov 29, 2006) - Bug/feature request - Contact Administrators