Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Com o código a seguir, uma tarefa é adicionada a uma fila com opções.
Em index.html:
<!-- A basic index.html file served from the "/" URL. -->
<html>
<body>
<p>Enqueue a value, to be processed by a worker.</p>
<form action="/enqueue" method="post">
<input type="text" name="key">
<input type="submit">
</form>
</body>
</html>
Em Enqueue.java:
// The Enqueue servlet should be mapped to the "/enqueue" URL.// With @WebServlet annotation the webapp/WEB-INF/web.xml is no longer required.@WebServlet(name="TaskEnque",description="taskqueue: Enqueue a job with a key",urlPatterns="/taskqueues/enqueue")publicclassEnqueueextendsHttpServlet{protectedvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{Stringkey=request.getParameter("key");// Add the task to the default queue.Queuequeue=QueueFactory.getDefaultQueue();queue.add(TaskOptions.Builder.withUrl("/worker").param("key",key));response.sendRedirect("/");}}
Em Worker.java:
// The Worker servlet should be mapped to the "/worker" URL.// With @WebServlet annotation the webapp/WEB-INF/web.xml is no longer required.@WebServlet(name="TaskWorker",description="TaskQueues: worker",urlPatterns="/taskqueues/worker")publicclassWorkerextendsHttpServlet{privatestaticfinalLoggerlog=Logger.getLogger(Worker.class.getName());protectedvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{Stringkey=request.getParameter("key");// Do something with key.// ...}}
As tarefas adicionadas a essa fila são executadas chamando o gerenciador de solicitações no URL /worker com o parâmetro key. Elas são executadas com a taxa definida no arquivo queue.xml ou com a taxa padrão de cinco tarefas por segundo.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-03-06 UTC."],[],[]]