Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.

Chapter 30. Asynchronous Job Service


The RESTEasy Asynchronous Job Service is an implementation of the Asynchronous Job pattern defined in O'Reilly's Restful Web Services. It is designed to add asynchronicity to a synchronous protocol.

30.1. Using Async Jobs

While HTTP is a synchronous protocol, it is capable of dealing with asynchronous invocations. The HTTP 1.1 response code 202 (Accepted) means that the server has received and accepted the response for processing, but that processing is not yet complete. The RESTEasy Asynchronous Job Service is based on this type of response.
POST http://example.com/myservice?asynch=true
Copy to Clipboard Toggle word wrap
For example, if you make the above post with the asynch query parameter set to true, RESTEasy returns a 202 (Accepted) response code and runs the invocation in the background. It also returns a Location header with a URL pointing to the location of the background method's response.
HTTP/1.1 202 Accepted
Location: http://example.com/asynch/jobs/3332334
Copy to Clipboard Toggle word wrap
The URI will have the form of:
/asynch/jobs/{job-id}?wait={millisconds}|nowait=true
Copy to Clipboard Toggle word wrap
You can perform GET, POST and DELETE operations on this job URL. GET returns the response of the JAX-RS resource method, if the job has completed. If the job has not completed, this GET returns a response code of 202 (Accepted). Invoking GET does not remove the job, so it can be called multiple times. When RESTEasy's job queue becomes full, it will evict the least recently used job from memory. You can clean the queue manually by calling DELETE on the URI. POST reads the JOB response and removes the JOB when it has completed.
Both GET and POST let you specify a mazimum wait time in milliseconds — a wait query parameter. For example:
POST http://example.com/asynch/jobs/122?wait=3000
Copy to Clipboard Toggle word wrap
If you do not specify a wait parameter, the GET or POST will not wait at all if the job is not complete.

Note

While you can invoke GET, DELETE, and PUT methods asynchronously, this breaks the HTTP 1.1 contract of these methods. These invocations may not change the state of the resource if invoked more than once, but they do change the state of the server. Try to invoke POST methods asynchronously.

Important

RESTEasy role-based security (annotations) does not work with the Asynchronous Job Service. You must use XML declarative security within your web.xml file. It is currently impossible to implement role-based security portably. In the future, we may have specific JBoss integration, but will not support other environments.
Nach oben
Red Hat logoGithubredditYoutubeTwitter

Lernen

Testen, kaufen und verkaufen

Communitys

Über Red Hat Dokumentation

Wir helfen Red Hat Benutzern, mit unseren Produkten und Diensten innovativ zu sein und ihre Ziele zu erreichen – mit Inhalten, denen sie vertrauen können. Entdecken Sie unsere neuesten Updates.

Mehr Inklusion in Open Source

Red Hat hat sich verpflichtet, problematische Sprache in unserem Code, unserer Dokumentation und unseren Web-Eigenschaften zu ersetzen. Weitere Einzelheiten finden Sie in Red Hat Blog.

Über Red Hat

Wir liefern gehärtete Lösungen, die es Unternehmen leichter machen, plattform- und umgebungsübergreifend zu arbeiten, vom zentralen Rechenzentrum bis zum Netzwerkrand.

Theme

© 2025 Red Hat