title: providing timeout execution for a Spring AOP Aspect
body: <p>How I can provide a timeout execution to a Spring AOP Aspect ?</p>
  
  <p>The <strong>logger</strong> method of <strong>MyAspect</strong> shouldn't take more time execution than 30 seconds, if not i would want to stop the method execution. How i can do this ?</p>
  
  <p><strong>MyAspect Code :</strong> </p>
  
  <pre><code>@Aspect
  @Component
  public class MyAspect {
  
       @Autowired
       private myService myService;
  
       @AfterReturning(pointcut = "execution(* xxxxx*(..))", returning = "paramOut")
       public void logger(final JoinPoint jp, Object paramOut){
           Event event = (Event) paramOut;
           myService.save(event);
       }
  }
  </code></pre>
  
  <p><strong>myService Interface :</strong> </p>
  
  <pre><code>public interface myService {
      void save(Event event);
  }
  </code></pre>
  
  <p><strong>myServiceImpl :</strong></p>
  
  <pre><code>@Service
  @Transactional
  public class myServiceImpl implements myService {
  
      @PersistenceContext
      private EntityManager entityManager;
  
      @Override
      public void save(Event event) {
          entityManager.persist(event);
      }
  }
  </code></pre>