acs-aem-commons
acs-aem-commons copied to clipboard
ACS commons | Emails getting triggered multiple times
Required Information
[AEM6.5 , service pack 6.5.12.0 ] [ACS commons version : 5.6.0 ] [ yes]
Expected Behavior
we are getting multiple success emails upon successful translation request cross checked with our code base and we are triggering it only single time . but we are getting multiple mails in response , so we need help with ACS commons and logs
attaching screen shot
Actual Behavior
we have got multiple emails after the translation submission
Steps to Reproduce
https://adobe-consulting-services.github.io/acs-aem-commons/features/e-mail/email-api/index.html
Links
Analysis: function from class TranslationJobEventListener
@Override
public void onEvent(EventIterator eventIterator) {
try (ResourceResolver resolver = resolverFactory.getServiceResourceResolver(Collections
.singletonMap(ResourceResolverFactory.SUBSERVICE, TranslationJobEventListener.class.getName()))) {
LOG.debug("Befpre If {}");
if (eventIterator.hasNext()) {
LOG.debug("inside If {}");
Optional<TranslationJob> optionalTranslationJob = Optional.ofNullable(getFinishedTranslationJob(eventIterator.nextEvent(), resolver));
optionalTranslationJob.ifPresent(finishedTranslationJob -> {
LOG.debug("Received TranslationJob with ID!: {}", finishedTranslationJob.getId());
if (finishedTranslationJob != null) {
LOG.debug("Fetching value finishedtransalation job! {}",finishedTranslationJob.getSources() );
PageManager pageManager = resolver.adaptTo(PageManager.class);
checkXfSyncTarget(finishedTranslationJob, pageManager, resolver);
LOG.debug("Sending emails before rollout!");
sendEmails(finishedTranslationJob, resolver);
LOG.debug("logging after sending emails! {}");
rolloutPages(finishedTranslationJob, pageManager);
LOG.debug("logging after rolling the pages! {}");
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
scheduler.schedule(() -> {
publishPages(finishedTranslationJob);
}, 15, TimeUnit.MINUTES);
}
});
}
@1prasanthyndluri are you sure you arent calling the Email service multiple times? Or maybe youre sending it to the same recipient multiple times (since the service can take a list of email recipients)?
If you look at the code, the only looping that might do this is based on the list of recipients you pass in - so make sure you arent sending in the same email address multiple times.
https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/master/bundle/src/main/java/com/adobe/acs/commons/email/impl/EmailServiceImpl.java
All the ACS Commons mail service does is call the OOTB AEM Mail service.
hi @davidjgonzalez I have checked the code multiple times, and couldn't find any issue. We are not triggering emails multiple times. Email is being triggered only one time but the issue is for one succesfull trigger we have got lot of emails send to recipents