Summary
Add DaprClient.invokeHttpClient(appId) — an SDK-native factory that returns an HTTP client preconfigured for Dapr service invocation, as the successor to the invokeMethod(...) overloads deprecated by #1666.
Motivation
After #1666, every DaprClient.invokeMethod(...) overload is @Deprecated, with the javadoc telling users to "use language-native HTTP clients or gRPC clients for service invocation instead." However, the SDK provides no SDK-native replacement, so any user who wants to keep going through DaprClient must hand-roll:
- Dapr endpoint/port resolution,
/v1.0/invoke/<app-id>/method/<method> URL composition,
dapr-api-token header injection,
- and the lifecycle of their own
java.net.http.HttpClient.
The .NET SDK already solves this with DaprClient.CreateInvokeHttpClient(appId), which returns a System.Net.Http.HttpClient whose BaseAddress is the Dapr invoke prefix for the target app and which auto-attaches the api token — letting users write await httpClient.GetAsync("weatherforecast") directly.
Proposed API
DaprInvokeHttpClient invoker = daprClient.invokeHttpClient("orderprocessor");
HttpRequest request = invoker.newRequestBuilder("orders")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = invoker.send(request, HttpResponse.BodyHandlers.ofString());
The returned DaprInvokeHttpClient:
- resolves relative paths against
{daprHttpEndpoint}/v1.0/invoke/{appId}/method/,
- attaches the
dapr-api-token header when configured,
- reuses the SDK's shared
java.net.http.HttpClient (no extra lifecycle for the caller),
- and exposes the underlying
httpClient() and baseUri() as escape hatches.
References
Release Note
RELEASE NOTE: ADD DaprClient.invokeHttpClient(appId) factory — an SDK-native HTTP client preconfigured for service invocation, mirroring .NET's CreateInvokeHttpClient and serving as the successor to the deprecated invokeMethod APIs.
Summary
Add
DaprClient.invokeHttpClient(appId)— an SDK-native factory that returns an HTTP client preconfigured for Dapr service invocation, as the successor to theinvokeMethod(...)overloads deprecated by #1666.Motivation
After #1666, every
DaprClient.invokeMethod(...)overload is@Deprecated, with the javadoc telling users to "use language-native HTTP clients or gRPC clients for service invocation instead." However, the SDK provides no SDK-native replacement, so any user who wants to keep going throughDaprClientmust hand-roll:/v1.0/invoke/<app-id>/method/<method>URL composition,dapr-api-tokenheader injection,java.net.http.HttpClient.The .NET SDK already solves this with
DaprClient.CreateInvokeHttpClient(appId), which returns aSystem.Net.Http.HttpClientwhoseBaseAddressis the Dapr invoke prefix for the target app and which auto-attaches the api token — letting users writeawait httpClient.GetAsync("weatherforecast")directly.Proposed API
The returned
DaprInvokeHttpClient:{daprHttpEndpoint}/v1.0/invoke/{appId}/method/,dapr-api-tokenheader when configured,java.net.http.HttpClient(no extra lifecycle for the caller),httpClient()andbaseUri()as escape hatches.References
DaprClient.CreateInvokeHttpClient(appId).Release Note
RELEASE NOTE: ADD
DaprClient.invokeHttpClient(appId)factory — an SDK-native HTTP client preconfigured for service invocation, mirroring .NET'sCreateInvokeHttpClientand serving as the successor to the deprecatedinvokeMethodAPIs.