Class TinyMailServiceImpl

  • All Implemented Interfaces:
    org.springframework.beans.factory.InitializingBean , pro.fessional.wings.tiny.mail.service.TinyMailService

    @Service()@ConditionalWingsEnabled() 
    public class TinyMailServiceImpl
     implements TinyMailService, InitializingBean
                        
    Since:

    2023-01-06

    Author:

    trydofor

    • Field Summary

      Fields 
      Modifier and Type Field Description
      public final static int Success
      public final static int ErrCheck
      public final static int ErrOther
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      boolean send(@NotNull() TinyMail message, boolean retry)
      Save first, then Sync single send. and return,
      - true, if send success.
      - false, if check fail, e.g. prop, lock or format.
      - throw if send fail, MailRetryException if async retry.
      
      long post(@NotNull() TinyMail message, boolean retry)
      Save first, then Sync single send, fire and forget, no exception throw. and return,
      - {@value #ErrOther}, if throw non MailRetryException.
      - {@value #ErrCheck}, if check fail, e.g. prop, lock or format.
      - {@value #Success}, if send success.
      - mills > now(), estimated retry time, if fail and async retry
      
      long emit(@NotNull() TinyMail message, boolean retry)
      Save first, then Async batch send, fire and forget, no exception throw. and return,
      - {@value #ErrOther}, if throw non MailRetryException.
      - {@value #ErrCheck}, if check fail, e.g. prop, lock or format.
      - mills > now(), estimated send or retry (when error) time
      
      boolean send(long id, boolean retry, boolean check)
      Save first, then Sync single send. and return,
      - true, if send success.
      - false, if check fail, e.g. prop, lock or format.
      - throw if send fail, MailRetryException if async retry.
      
      long post(long id, boolean retry, boolean check)
      Save first, then Sync single send, fire and forget, no exception throw. and return,
      - {@value #ErrOther}, if throw non MailRetryException.
      - {@value #ErrCheck}, if check fail, e.g. prop, lock or format.
      - {@value #Success}, if send success.
      - mills > now(), estimated retry time, if fail and async retry
      
      long emit(long id, boolean retry, boolean check)
      Save first, then Async batch send, fire and forget, no exception throw. and return,
      - {@value #ErrOther}, if throw non MailRetryException.
      - {@value #ErrCheck}, if check fail, e.g. prop, lock or format.
      - mills > now(), estimated send or retry (when error) time
      
      void afterPropertiesSet()
      void destroy()
      long save(@NotNull() TinyMailPlain msg, boolean check) Create(id is empty) or edit a mail with check, return the id.
      int scan(Long idle)
      Sync scan the unsent mail to resend them async, return the count. and if idel is
      * null, only scan, nothing to idle
      * > 0, adjust the scheduled scan interval mills
      * = 0, disable the scheduled scan
      * < 0, reset to scan-idle prop if adjusted before
      
      ArrayList<TinyMailServiceImpl.AsyncMail> listAsyncMailQueue()
      TreeMap<Long, ScheduledFuture<out Object>> listAsyncMailTask()
      void setAppName(String appName)
      void setLightIdService(LightIdService lightIdService)
      void setJournalService(JournalService journalService)
      void setWinMailSenderDao(WinMailSenderDao winMailSenderDao)
      void setMailConfigProvider(MailConfigProvider mailConfigProvider)
      void setMailSenderManager(MailSenderManager mailSenderManager)
      void setTinyMailServiceProp(TinyMailServiceProp tinyMailServiceProp)
      void setResourceLoader(ResourceLoader resourceLoader)
      void setStatusHookProvider(ObjectProvider<TinyMailService.StatusHook> statusHookProvider)
      void setLazyBeanProvider(ObjectProvider<TinyMailLazy> lazyBeanProvider)
      • Methods inherited from class pro.fessional.wings.tiny.mail.service.TinyMailService

        auto, auto, emit, post, save, scan, send
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TinyMailServiceImpl

        TinyMailServiceImpl()
    • Method Detail

      • send

         boolean send(@NotNull() TinyMail message, boolean retry)
        Save first, then Sync single send. and return,
        - true, if send success.
        - false, if check fail, e.g. prop, lock or format.
        - throw if send fail, MailRetryException if async retry.
        
      • post

         long post(@NotNull() TinyMail message, boolean retry)
        Save first, then Sync single send, fire and forget, no exception throw. and return,
        - {@value #ErrOther}, if throw non MailRetryException.
        - {@value #ErrCheck}, if check fail, e.g. prop, lock or format.
        - {@value #Success}, if send success.
        - mills > now(), estimated retry time, if fail and async retry
        
      • emit

         long emit(@NotNull() TinyMail message, boolean retry)
        Save first, then Async batch send, fire and forget, no exception throw. and return,
        - {@value #ErrOther}, if throw non MailRetryException.
        - {@value #ErrCheck}, if check fail, e.g. prop, lock or format.
        - mills > now(), estimated send or retry (when error) time
        
      • send

         boolean send(long id, boolean retry, boolean check)
        Save first, then Sync single send. and return,
        - true, if send success.
        - false, if check fail, e.g. prop, lock or format.
        - throw if send fail, MailRetryException if async retry.
        
      • post

         long post(long id, boolean retry, boolean check)
        Save first, then Sync single send, fire and forget, no exception throw. and return,
        - {@value #ErrOther}, if throw non MailRetryException.
        - {@value #ErrCheck}, if check fail, e.g. prop, lock or format.
        - {@value #Success}, if send success.
        - mills > now(), estimated retry time, if fail and async retry
        
      • emit

         long emit(long id, boolean retry, boolean check)
        Save first, then Async batch send, fire and forget, no exception throw. and return,
        - {@value #ErrOther}, if throw non MailRetryException.
        - {@value #ErrCheck}, if check fail, e.g. prop, lock or format.
        - mills > now(), estimated send or retry (when error) time
        
      • destroy

        @EventListener(value = ContextClosedEvent.class) void destroy()
      • save

         long save(@NotNull() TinyMailPlain msg, boolean check)

        Create(id is empty) or edit a mail with check, return the id. NOTE: no schedule to send, need manually send/post/emit it.

      • scan

         int scan(Long idle)
        Sync scan the unsent mail to resend them async, return the count. and if idel is
        * null, only scan, nothing to idle
        * > 0, adjust the scheduled scan interval mills
        * = 0, disable the scheduled scan
        * < 0, reset to scan-idle prop if adjusted before
        
      • setAppName

        @Value(value = "${spring.application.name}") void setAppName(String appName)
      • setLightIdService

        @Autowired() void setLightIdService(LightIdService lightIdService)
      • setJournalService

        @Autowired() void setJournalService(JournalService journalService)
      • setResourceLoader

        @Autowired() void setResourceLoader(ResourceLoader resourceLoader)