Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.이 콘텐츠는 선택한 언어로 제공되지 않습니다.
40.5. Catching Exceptions Returned from a Remote Service
Overview 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
Consumers making asynchronous requests will not receive the same exceptions returned than when they make synchronous requests. Any exceptions returned to the consumer asynchronously are wrapped in an
ExecutionException
exception. The actual exception thrown by the service is stored in the ExecutionException
exception's cause
field.
Catching the exception 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
Exceptions generated by a remote service are thrown locally by the method that passes the response to the consumer's business logic. When the consumer makes a synchronous request, the method making the remote invocation throws the exception. When the consumer makes an asynchronous request, the
Response<T>
object's get()
method throws the exception. The consumer will not discover that an error was encountered in processing the request until it attempts to retrieve the response message.
Unlike the methods generated by the JAX-WS framework, the
Response<T>
object's get()
method does not throw either user modeled exceptions nor the generic JAX-WS exceptions. Instead, it throws a java.util.concurrent.ExecutionException
exception.
Getting the exception details 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
The framework stores the exception returned from the remote service in the
ExecutionException
exception's cause
field. The details about the remote exception are extracted by getting the value of the cause
field and examining the stored exception. The stored exception can be any user defined exception or one of the generic JAX-WS exceptions.
Example 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
Example 40.11, “Catching an Exception using the Polling Approach” shows an example of catching an exception using the polling approach.
Example 40.11. Catching an Exception using the Polling Approach
The code in Example 40.11, “Catching an Exception using the Polling Approach” does the following:
If the consumer was using the callback approach the code used to catch the exception would be placed in the callback object where the service's response is extracted.