이 콘텐츠는 선택한 언어로 제공되지 않습니다.

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
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
The URI will have the form of:
/asynch/jobs/{job-id}?wait={millisconds}|nowait=true
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 maximum wait time in milliseconds — a wait query parameter. For example:
POST http://example.com/asynch/jobs/122?wait=3000
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.
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat
맨 위로 이동