I want to execute a method once the Eureka Client registers in Eureka Server. I have written the below code but the code inside onApplicationEvent() method is not getting executed after Client registers in Eureka Server. But the application is getting registered in Eureka Server.

I have followed the below url and tried but it didn't work.

https://github.com/spring-cloud/spring-cloud-netflix/issues/1679

@SpringBootApplication
@ComponentScan(basePackages = { "com.xxx.network.inventory.oss.staticcontent", "com.xxx.commons.rest*"},
excludeFilters={
          @ComponentScan.Filter(type=FilterType.ASSIGNABLE_TYPE, value=RestTemplateConfig.class)})
@EnableEurekaClient
public class OssUiApplication implements ApplicationListener<EurekaInstanceRegisteredEvent> {

    public static void main(String[] args) {
        SpringApplication.run(OssUiApplication.class, args);
    }

    @Override
    public void onApplicationEvent(EurekaInstanceRegisteredEvent event) {
        System.out.println("Got it...");
    }
}

Please help me to execute a method just after the Client gets registered in Eureka server.

Comment From: OlgaMaciaszek

@suryadip08 , you should listen to org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent instead.