Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eureka doesn't work with Java EE application #1561

Open
bulat3103 opened this issue Nov 18, 2024 · 0 comments
Open

Eureka doesn't work with Java EE application #1561

bulat3103 opened this issue Nov 18, 2024 · 0 comments

Comments

@bulat3103
Copy link

bulat3103 commented Nov 18, 2024

Please help me figure out the problem. I have a Java EE application that is deployed in a kubernetes cluster on Wildfly 18.0.1. Eureka is also deployed in this cluster. I use this Maven dependency in my Java application:

<dependency>
    <groupId>com.netflix.eureka</groupId>
    <artifactId>eureka-client</artifactId>
    <version>1.10.14</version>
</dependency>

This is the class that is responsible for registering and de-registering an application instance in Eureka:

@WebListener
public class ServerStartup implements javax.servlet.ServletContextListener{
    @Override
    public void contextDestroyed(ServletContextEvent arg0) {
        EurekaClientService.getInstance().deRegister();
    }

    @Override
    public void contextInitialized(ServletContextEvent arg0) {
        EurekaClientService.getInstance().registerInstance();
    }
}

deRegister method in EurekaClientService:

public void deRegister() {

    applicationInfoManager.setInstanceStatus(InstanceInfo.InstanceStatus.DOWN);
        sendHeartBeat();
        if(eurekaClient != null){
            eurekaClient.shutdown();
        }
        else{
            log.warn("eurekaClient is NULL, can't deRegister()");
        }

    }

    public void sendHeartBeat(){
        applicationInfoManager.refreshLeaseInfoIfRequired();
    }
applicationInfoManager - com.netflix.appinfo.ApplicationInfoManager
eurekaClient - com.netflix.discovery.EurekaClient

The problem is that after the application is completed, it is not automatically unregistered from Eureka and, accordingly, Eureka remembers about it for some more time, which is incorrect behavior for me

I think it may be due to the library itself being used, that it cannot work with Java EE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant