Package org.apache.dubbo.rpc
Interface Result
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
AppResponse,AsyncRpcResult
(API, Prototype, NonThreadSafe)
An RPC
Result.
Known implementations are:
1. AsyncRpcResult, it's a CompletionStage whose underlying value signifies the return value of an RPC call.
2. AppResponse, it inevitably inherits CompletionStage and Future, but you should never treat AppResponse as a type of Future,
instead, it is a normal concrete type.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttachments(Map<String, String> map) Add the specified map to existing attachments in this instance.voidaddObjectAttachments(Map<String, Object> map) Add the specified map to existing attachments in this instance.get()getAttachment(String key) get attachment by key.getAttachment(String key, String defaultValue) get attachment by key with default value.get attachments.Get exception.get attachment by key.getObjectAttachment(String key, Object defaultValue) get attachment by key with default value.get attachments.getValue()Get invoke result.booleanHas exception.recreate()Recreate.voidsetAttachment(String key, Object value) voidsetAttachment(String key, String value) voidsetAttachments(Map<String, String> map) Replace the existing attachments with the specified param.voidvoidsetObjectAttachment(String key, Object value) voidsetObjectAttachments(Map<String, Object> map) Replace the existing attachments with the specified param.void<U> CompletableFuture<U> Add a callback which can be triggered when the RPC call finishes.
-
Method Details
-
getValue
Object getValue()Get invoke result.- Returns:
- result. if no result return null.
-
setValue
-
getException
Throwable getException()Get exception.- Returns:
- exception. if no exception return null.
-
setException
-
hasException
boolean hasException()Has exception.- Returns:
- has exception.
-
recreate
Recreate.if (hasException()) { throw getException(); } else { return getValue(); }- Returns:
- result.
- Throws:
Throwable
-
getAttachments
get attachments.- Returns:
- attachments.
-
getObjectAttachments
get attachments.- Returns:
- attachments.
-
addAttachments
Add the specified map to existing attachments in this instance.- Parameters:
map-
-
addObjectAttachments
Add the specified map to existing attachments in this instance.- Parameters:
map-
-
setAttachments
Replace the existing attachments with the specified param.- Parameters:
map-
-
setObjectAttachments
Replace the existing attachments with the specified param.- Parameters:
map-
-
getAttachment
get attachment by key.- Returns:
- attachment value.
-
getObjectAttachment
get attachment by key.- Returns:
- attachment value.
-
getAttachment
get attachment by key with default value.- Returns:
- attachment value.
-
getObjectAttachment
get attachment by key with default value.- Returns:
- attachment value.
-
setAttachment
-
setAttachment
-
setObjectAttachment
-
whenCompleteWithContext
Add a callback which can be triggered when the RPC call finishes.Just as the method name implies, this method will guarantee the callback being triggered under the same context as when the call was started, see implementation in
whenCompleteWithContext(BiConsumer)- Parameters:
fn-- Returns:
-
thenApply
-
get
-
get
Result get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
-