Java 8 ha raggiunto la fine del supporto
e verrà ritirato
il 31 gennaio 2026. Dopo il ritiro, non potrai eseguire il deployment di applicazioni Java 8, anche se la tua organizzazione ha utilizzato in precedenza un criterio dell'organizzazione per riattivare i deployment di runtime legacy. Le tue applicazioni Java 8 esistenti continueranno a essere eseguite e a ricevere traffico dopo la
data di ritiro. Ti consigliamo di eseguire la migrazione all'ultima versione supportata di Java.
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Il seguente codice aggiunge un'attività a una coda con opzioni.
In 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>
In 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("/");}}
In 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.// ...}}
Le attività aggiunte a questa coda verranno eseguite chiamando il gestore delle richieste all'URL /worker con il parametro key. Verranno eseguiti alla velocità impostata nel file queue.xml o alla velocità predefinita di 5 attività al secondo.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-08-04 UTC."],[[["This content demonstrates how to add a task to a queue using legacy bundled services and APIs within the first-generation App Engine standard environment."],["The provided `index.html` includes a form to submit a value (`key`) to the `/enqueue` URL for task queuing."],["The `Enqueue.java` servlet handles POST requests to `/taskqueues/enqueue`, adding tasks with the provided `key` to the default queue."],["The `Worker.java` servlet, mapped to `/taskqueues/worker`, processes the tasks, receiving the `key` parameter for execution."],["Tasks in the queue are executed by calling the `/worker` request handler, with the rate determined by the `queue.xml` file or defaulting to 5 tasks per second."]]],[]]