Search code examples
javagoogle-app-enginegae-modulegae-backends

How can a Java program tell which "backend" it is when using AppEngine Modules?


It used to be that a Java program running on AppEngine could tell what backend it was by calling:

BackendService backendservice = BackendServiceFactory.getBackendService();
String currentbackend = backendservice.getCurrentBackend();

The BackendService has been deprecated with the advent of "modules" but you can still deploy an app under multiple "named versions" to get the same effect should you not want to move on to full modules.

How though, using this new system, should a program determine which backend/version it is without using the deprecated code?


Solution

  • You can use

    ModulesService modulesService = ModulesServiceFactory.getModulesService();
    
    modulesService.getCurrentModule();
    modulesService.getCurrentVersion();
    modulesService.getCurrentInstanceId();