I'm trying to implement an event that is monitored by a listener, but Spring does not call the Listener ...
Event:
import org.springframework.context.ApplicationEvent;
public class CustomSpringEvent extends ApplicationEvent {
private static final long serialVersionUID = 1L;
private String message;
public CustomSpringEvent(Object source, String message) {
super(source);
this.message = message;
}
public String getMessage() {
return message;
}
}
Listener
@Component
public class CustomSpringEventListener implements ApplicationListener<CustomSpringEvent> {
@Override
public void onApplicationEvent(CustomSpringEvent event) {
System.out.println("MENSAGEM RETORNADA PELO EVENTO: "+event.getMessage());
}
}
Event call
CustomSpringEvent customSpringEvent = new CustomSpringEvent(this, "ALKSDJFASLKDJFASLKDFJALKSDJFSKDJ");
publisher.publishEvent(customSpringEvent);