Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-13650

@EventListener does not work if put it at method in class that implements interface

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 4.2.2
    • Fix Version/s: 4.2.3
    • Component/s: None
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      Simple example:

      public interface Service{
            @org.springframework.context.event.EventListener
            void processEventA(EventA event);
            
            void processEventB(EventB event);
      }
      
      @Service
      public class ServiceImpl implements Service{
           @Override
           public void void processEventA(EventA event){ 
                //do something 
           }
      
           @Override
           @org.springframework.context.event.EventListener
           public void void processEventB(EventB event){ 
                //do something 
           }
      
           @org.springframework.context.event.EventListener
           public void void processEventC(EventC event){ 
                //do something 
           }
      }
      
      @Service
      public class EventPublisher{
             @Autowired
             ApplicationEventPublisher eventPublisher;
      
             public void publishEvents(){
                   eventPublisher.publishEvent(new EventA());
                   eventPublisher.publishEvent(new EventB());
                   eventPublisher.publishEvent(new EventC());
             }
      }
      

      When I call EventPublisher.publishEvents() only one method in ServiceImpl is triggered: processEventA(EventA event). But I expected that all three methods will be triggered.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                juergen.hoeller Juergen Hoeller
                Reporter:
                Nazar Vishka Nazar Vishka
                Last updater:
                Juergen Hoeller
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  2 years, 28 weeks, 1 day ago