Package io.jmix.email.impl
Class EmailerImpl
java.lang.Object
io.jmix.email.impl.EmailerImpl
- All Implemented Interfaces:
Emailer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.springframework.context.ApplicationContextprotected SystemAuthenticatorprotected AtomicIntegerprotected EmailCleanerprotected EmailDataProviderprotected EmailerPropertiesprotected EmailSenderprotected org.springframework.core.task.TaskExecutorprotected Metadataprotected MetadataToolsprotected io.micrometer.core.instrument.MeterRegistry -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected SendingMessageconvertToSendingMessage(EmailInfo info, @Nullable Integer attemptsLimit, @Nullable Date deadline) protected SendingMessagecreateClone(SendingMessage srcMessage) protected org.springframework.core.task.TaskExecutorprotected voidprotected StringgetContentBodyType(SendingMessage sendingMessage) protected voidprotected booleanprotected voidpersistAndSendEmail(EmailInfo emailInfo) protected @Nullable SendingMessagepersistMessageIfPossible(SendingMessage sendingMessage) protected voidprepareEmailInfo(EmailInfo emailInfo) Send emails added to the queue.protected voidvoidSend email synchronously.voidsendEmail(String address, String subject, String body, String bodyContentType, Boolean important, EmailAttachment... attachment) Send email synchronously.sendEmailAsync(EmailInfo info) Send email asynchronously.sendEmailAsync(EmailInfo info, @Nullable Integer attemptsLimit, @Nullable Date deadline) Send email asynchronously, with limited number of attempts.protected Stringprotected voidsendSendingMessage(SendingMessage sendingMessage) protected voidprotected SendingAttachment
-
Field Details
-
emailerProperties
-
callCount
-
emailDataProvider
-
metadata
-
authenticator
-
emailSender
-
metadataTools
-
applicationContext
@Autowired protected org.springframework.context.ApplicationContext applicationContext -
emailCleaner
-
meterRegistry
@Autowired protected io.micrometer.core.instrument.MeterRegistry meterRegistry -
mailSendTaskExecutor
protected org.springframework.core.task.TaskExecutor mailSendTaskExecutor
-
-
Constructor Details
-
EmailerImpl
public EmailerImpl()
-
-
Method Details
-
initMailSendTaskExecutor
@PostConstruct protected void initMailSendTaskExecutor() -
destroyMailSendTaskExecutor
- Throws:
Exception
-
sendEmail
public void sendEmail(String address, String subject, String body, String bodyContentType, Boolean important, EmailAttachment... attachment) throws EmailException Description copied from interface:EmailerSend email synchronously.- Specified by:
sendEmailin interfaceEmailer- Parameters:
address- comma or semicolon separated list of addressessubject- email subjectbody- email bodybodyContentType- email body like "text/plain; charset=UTF-8" or "text/html; charset=UTF-8", etcattachment- email attachments- Throws:
EmailException- in case of any errors
-
sendEmail
Description copied from interface:EmailerSend email synchronously.- Specified by:
sendEmailin interfaceEmailer- Parameters:
info- email details- Throws:
EmailException- in case of any errors
-
sendEmailAsync
Description copied from interface:EmailerSend email asynchronously.This method creates a
SendingMessage, saves it to the database and returns immediately. The actual sending is performed by theEmailer.processQueuedEmails()method which should be invoked by a scheduled task.- Specified by:
sendEmailAsyncin interfaceEmailer- Parameters:
info- email details- Returns:
- created
SendingMessage
-
sendEmailAsync
public SendingMessage sendEmailAsync(EmailInfo info, @Nullable Integer attemptsLimit, @Nullable Date deadline) Description copied from interface:EmailerSend email asynchronously, with limited number of attempts.- Specified by:
sendEmailAsyncin interfaceEmailer- Parameters:
info- email detailsattemptsLimit- count of attempts to send (1 attempt per scheduler tick). If not specified,EmailerProperties.getDefaultSendingAttemptsLimit()is useddeadline- Emailer tries to send message till deadline. If deadline has come and message has not been sent, status of this message is changed toSendingStatus.NOT_SENT- Returns:
- created
SendingMessage
-
prepareEmailInfo
-
convertToSendingMessage
protected SendingMessage convertToSendingMessage(EmailInfo info, @Nullable Integer attemptsLimit, @Nullable Date deadline) -
sendSendingMessage
-
persistAndSendEmail
- Throws:
EmailException
-
persistMessageIfPossible
-
createClone
-
processQueuedEmails
Description copied from interface:EmailerSend emails added to the queue.This method should be called periodically from a scheduled task.
- Specified by:
processQueuedEmailsin interfaceEmailer- Returns:
- short message describing how many emails were sent, or error message
-
sendQueuedEmails
-
submitExecutorTask
-
getContentBodyType
-
replaceRecipientIfNecessary
-
createMailSendTaskExecutor
protected org.springframework.core.task.TaskExecutor createMailSendTaskExecutor() -
bindMailSendTaskExecutorMetrics
protected void bindMailSendTaskExecutorMetrics() -
toSendingAttachment
-
isNeedToRetry
-