Blame | Last modification | View Log | RSS feed
package com.spice.profitmandi.service.mail;import com.spice.profitmandi.common.mail.MailQueue;import com.spice.profitmandi.common.mail.MailRequest;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;/*** Publishes {@link MailOutboxService} as a {@link MailQueue} without letting* MailOutboxService implement the interface itself.** That indirection is load-bearing. MailOutboxService has @Transactional methods,* so Spring must proxy it, and @EnableTransactionManagement here runs with the* default proxyTargetClass=false. While the class implements no interface Spring* proxies it with a CGLIB subclass, which is still a MailOutboxService. The moment* it implements one, Spring switches to a JDK proxy that implements only that* interface -- and the 39 sites which inject the concrete MailOutboxService all* fail with BeanNotOfRequiredTypeException, taking the whole context down with* them. That is exactly what happened in production on 2026-08-31.** So the interface lives here instead: this adapter carries no transactional* annotations, and its consumers (MailQueueHolder, EmailServiceImpl) inject it by* the MailQueue interface, which a proxy of either kind satisfies.*/@Servicepublic class MailQueueAdapter implements MailQueue {private final MailOutboxService mailOutboxService;@Autowiredpublic MailQueueAdapter(MailOutboxService mailOutboxService) {this.mailOutboxService = mailOutboxService;}@Overridepublic void queue(MailRequest request) {mailOutboxService.queue(request);}}