// Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java
// @Repository
// public interface EmailRepository extends JpaRepository<Email,Long>{
// 
//     @Transactional
//     @Modifying
//     @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true)
//     int deleteEmailsExceedingDateRetentionLimit(int maxNumber);
// }


import de.gessnerfl.fakesmtp.repository.EmailRepository;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.subethamail.smtp.helper.SimpleMessageListener;
import java.io.IOException;
import java.io.InputStream;
package de.gessnerfl.fakesmtp.server.impl;



@Service
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = IOException.class)
public class MessageListener implements SimpleMessageListener {
    private final EmailFactory emailFactory;
    private final EmailFilter emailFilter;
// Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java
// @Repository
// public interface EmailRepository extends JpaRepository<Email,Long>{
// 
//     @Transactional
//     @Modifying
//     @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true)
//     int deleteEmailsExceedingDateRetentionLimit(int maxNumber);
// }


// Path: src/main/java/de/gessnerfl/fakesmtp/server/impl/MessageListener.java
import de.gessnerfl.fakesmtp.repository.EmailRepository;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.subethamail.smtp.helper.SimpleMessageListener;
import java.io.IOException;
import java.io.InputStream;

package de.gessnerfl.fakesmtp.server.impl;



@Service
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = IOException.class)
public class MessageListener implements SimpleMessageListener {
    private final EmailFactory emailFactory;
    private final EmailFilter emailFilter;
    private final EmailRepository emailRepository;