Subversion Repositories SmartDukaan

Rev

Rev 35960 | Rev 36067 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 35960 Rev 36059
Line 203... Line 203...
203
 
203
 
204
    @Async("mailOutboxExecutor")
204
    @Async("mailOutboxExecutor")
205
    @Transactional(propagation = Propagation.REQUIRES_NEW)
205
    @Transactional(propagation = Propagation.REQUIRES_NEW)
206
    public void sendMailAsync(long mailOutboxId) {
206
    public void sendMailAsync(long mailOutboxId) {
207
        try {
207
        try {
208
            MailOutbox mail = mailOutboxRepository.selectPending().stream()
208
            MailOutbox mail = mailOutboxRepository.findById(mailOutboxId);
-
 
209
            if (mail == null) {
209
                    .filter(m -> m.getId() == mailOutboxId)
210
                LOGGER.warn("Mail not found for id={}", mailOutboxId);
210
                    .findFirst()
211
                return;
211
                    .orElse(null);
212
            }
212
            if (mail == null || "SENT".equals(mail.getStatus())) {
213
            if (!"PENDING".equals(mail.getStatus())) {
213
                return;
214
                return;
214
            }
215
            }
215
            sendAndUpdateStatus(mail);
216
            sendAndUpdateStatus(mail);
216
        } catch (Exception e) {
217
        } catch (Exception e) {
217
            LOGGER.error("Async mail send failed for mailOutboxId={}", mailOutboxId, e);
218
            LOGGER.error("Async mail send failed for mailOutboxId={}", mailOutboxId, e);