How to deploy a java microservice to an existing python-default standard environment app?

31 views
Skip to first unread message

rasmus

unread,
Feb 8, 2018, 5:24:27 PM2/8/18
to Google App Engine
As per topic.
I want to add a java service to my existing python app.

What does it take? All google java tutorials assume I'm building a full app, so the examples dont work for me.

Anyone have an example of deploying microservices in java?

I have root directory
my-app-VERSION
  +- default -- contains app.yaml, lots of python code
  +- worker -- contains worker.yaml, some python code

now I want to add
  javaworker -- containing pom.xml, build.gradle, some java code in src/main/com/mycompany/javaworker

gradle builds the WAR distribution alright, outputs my HelloService.class in the expected place.
But it can't deploy or run, claiming it can't find gcloud.
Gradle discussions seem to say it "currently" requires the default service to be a pom.xml (implying java i guess)

mvn appengine:run says that it's missing root pom.xml

I don't want to suddenly overwrite our main app with some empty java servlet.
What to do?




Jordan (Cloud Platform Support)

unread,
Feb 8, 2018, 11:25:54 PM2/8/18
to Google App Engine
You can think of services like completely different applications (which can be written in different languages), with each their own versions. Your main App Engine project then makes use of your different services by first accepting requests from the 'default' front-end Python service and version, then having the 'default' service/version make requests to your additional backend services' ('worker' and 'javaworker') default versions. 

Of course your clients can make direct requests to your other services instead of only the 'default' by using the services' routing URL. Therefore, since these are separate applications working together to form a project, each service has its own app.yaml (or appengine-web.xml for Java). Having separate configuration files allows you to then specify a different 'service' (if deploying with gcloud, else use 'module' if deploying with App Engine Maven plugin) in the configuration file. 

Now that you have separate services with unique configuration files, you can then run the deployment commands (gcloud or mvn appengine:deploy) from the root filtepaths (aka where their configuration files reside) to deploy a new version of that service to your App Engine project. 

- Note Google Groups is for general product discussions and is not for technical support. If your require further technical support for deploying services to your App Engine project, it is recommended to post your detailed questions to Stack Overflow using the supported Cloud tags. 

rasmus

unread,
Feb 9, 2018, 4:25:49 AM2/9/18
to Google App Engine
Thanks for reply.

I can upload and use a new python service easily, question is how to deploy services in different languages.
In my case, add a java non-default service when the default service is python.

Maven and gradle can't see that I have a default service already, since it's python, so they refuse to deploy.
And gcloud app deploy doesn't update java if I understand.

None of the java tutorials mention how to deploy and update a subservice, they only create complete single service default apps.
If I had an example perhaps I could adapt it and just update my new java.

Maybe it's not supported yet?
It might save me a lot of time to know this.

Thanks for any insights.

    /rasmus

Jordan (Cloud Platform Support)

unread,
Feb 9, 2018, 4:58:19 PM2/9/18
to Google App Engine
As previously described, you need to have an appengine-web.xml in the root directory of your Java service (this is the Java version of the app.yaml). You then set the actual <module>service_name</module> property in the appengine-web.xml and use the mvn appengine:deploy to deploy your Java code to your new service. 

I would recommend reviewing the Quick Start tutorial for Java to see what required configuration files are needed to deploy a Java service. You do not mix app.yaml and appengine-web.xml files, and you keep your services in separate root filepaths and deploy from those separate paths e.g:

my-app-folder
  +- default service folder -- contains app.yaml, Python code
  +- worker service folder -- contains worker.yaml, Python code
  +- javaworker service folder - contains appengine-web.xml, Java code

Your services then communicate with each other via HTTP URLFetch requests as per the documentations (since each service can only use one runtime language e.g Python OR Java). If you are instead requesting for multi-language support, this would indeed be a feature request and you can file this in the Public Issue Tracker

- For all further technical support, it is recommended to continue your questions on Stack Overflow using the supported Cloud tags. 
Reply all
Reply to author
Forward
0 new messages