Sample code for java backend in google appengine

When I read the doc backend, it tells how to configure, etc. What does the backend code look like? Is it just a servlet with additional entries in the backend.xml file?

I tried to create a servlet with class name com.xyz.Mybackend and servlet Mybackend.

public Mybackend extends HttpServlet{ public void doGet(HttpServletRequest req, HttpServletResponse resp){ while(true){ //do something try{ Thread.sleep(xyz); }catch(Exception ex){ } } } 

Then I added the following lines to backend.xml

 <backends> <backend name="Mybackend"> <class>B1</class> <options> <dynamic>true</dynamic> </options> </backend> </backends> 

Is this correct / sufficient? If yes. How do I start my backend now? Is he calling a link to a surfer servlet?

http://localhost/mybackenurl ?

+6
source share
2 answers
0
source

I know what you mean. I would find that the entire overview of the overview sections is much clearer the first time I read it, if at the top he said that the backends are just special instances of servlets.

A popular way to run backends that no one has mentioned here is to use push queues, as described here, https://developers.google.com/appengine/docs/java/taskqueue/overview-push#Java_Push_queues_and_backends

-1
source

Source: https://habr.com/ru/post/913887/


All Articles