Skip to content

Commit 9d8cf09

Browse files
Merge branch 'master' into docs-ver-sb
2 parents 14dbc41 + 7291d4c commit 9d8cf09

File tree

42 files changed

+1904
-52
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1904
-52
lines changed

.github/workflows/validate.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,10 @@ jobs:
216216
run: |
217217
mm.py README.md
218218
env:
219-
DOCKER_HOST: ${{steps.setup_docker.outputs.sock}}
219+
DOCKER_HOST: ${{steps.setup_docker.outputs.sock}}
220+
- name: Validate Spring Boot Workflow examples
221+
working-directory: ./spring-boot-examples/workflows
222+
run: |
223+
mm.py README.md
224+
env:
225+
DOCKER_HOST: ${{steps.setup_docker.outputs.sock}}

daprdocs/content/en/java-sdk-docs/java-client/_index.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,7 @@ You can initialize a Dapr client as so:
2424
DaprClient client = new DaprClientBuilder().build()
2525
```
2626

27-
This will connect to the default Dapr gRPC endpoint `localhost:50001`.
28-
29-
30-
#### Environment variables:
31-
32-
##### Dapr Sidecar Endpoints
33-
You can use the standardized `DAPR_GRPC_ENDPOINT` and `DAPR_HTTP_ENDPOINT` environment variables to
34-
specify a different gRPC or HTTP endpoint. When these variables are set, the client will automatically use them to connect to the Dapr sidecar.
35-
36-
The legacy environment variables `DAPR_HTTP_PORT` and `DAPR_GRPC_PORT` are still supported, but `DAPR_GRPC_ENDPOINT` and `DAPR_HTTP_ENDPOINT` take precedence.
37-
38-
##### Dapr API Token
39-
If your Dapr instance is configured to require the `DAPR_API_TOKEN` environment variable, you can
40-
set it in the environment and the client will use it automatically.
41-
You can read more about Dapr API token authentication [here](https://docs.dapr.io/operations/security/api-token/).
27+
This will connect to the default Dapr gRPC endpoint `localhost:50001`. For information about configuring the client using environment variables and system properties, see [Properties]({{< ref properties.md >}}).
4228

4329
#### Error Handling
4430

@@ -648,3 +634,5 @@ Learn more about the [Dapr Java SDK packages available to add to your Java appli
648634

649635
## Related links
650636
- [Java SDK examples](https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples)
637+
638+
For a full list of SDK properties and how to configure them, visit [Properties]({{< ref properties.md >}}).
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
---
2+
type: docs
3+
title: "Properties"
4+
linkTitle: "Properties"
5+
weight: 3001
6+
description: SDK-wide properties for configuring the Dapr Java SDK using environment variables and system properties
7+
---
8+
9+
# Properties
10+
11+
The Dapr Java SDK provides a set of global properties that control the behavior of the SDK. These properties can be configured using environment variables or system properties. System properties can be set using the `-D` flag when running your Java application.
12+
13+
These properties affect the entire SDK, including clients and runtime. They control aspects such as:
14+
- Sidecar connectivity (endpoints, ports)
15+
- Security settings (TLS, API tokens)
16+
- Performance tuning (timeouts, connection pools)
17+
- Protocol settings (gRPC, HTTP)
18+
- String encoding
19+
20+
## Environment Variables
21+
22+
The following environment variables are available for configuring the Dapr Java SDK:
23+
24+
### Sidecar Endpoints
25+
26+
When these variables are set, the client will automatically use them to connect to the Dapr sidecar.
27+
28+
| Environment Variable | Description | Default |
29+
|---------------------|-------------|---------|
30+
| `DAPR_GRPC_ENDPOINT` | The gRPC endpoint for the Dapr sidecar | `localhost:50001` |
31+
| `DAPR_HTTP_ENDPOINT` | The HTTP endpoint for the Dapr sidecar | `localhost:3500` |
32+
| `DAPR_GRPC_PORT` | The gRPC port for the Dapr sidecar (legacy, `DAPR_GRPC_ENDPOINT` takes precedence) | `50001` |
33+
| `DAPR_HTTP_PORT` | The HTTP port for the Dapr sidecar (legacy, `DAPR_HTTP_ENDPOINT` takes precedence) | `3500` |
34+
35+
### API Token
36+
37+
| Environment Variable | Description | Default |
38+
|---------------------|-------------|---------|
39+
| `DAPR_API_TOKEN` | API token for authentication between app and Dapr sidecar. This is the same token used by the Dapr runtime for API authentication. For more details, see [Dapr API token authentication](https://docs.dapr.io/operations/security/api-token/) and [Environment variables reference](https://docs.dapr.io/reference/environment/#dapr_api_token). | `null` |
40+
41+
### gRPC Configuration
42+
43+
#### TLS Settings
44+
For secure gRPC communication, you can configure TLS settings using the following environment variables:
45+
46+
| Environment Variable | Description | Default |
47+
|---------------------|-------------|---------|
48+
| `DAPR_GRPC_TLS_INSECURE` | When set to "true", enables insecure TLS mode which still uses TLS but doesn't verify certificates. This uses InsecureTrustManagerFactory to trust all certificates. This should only be used for testing or in secure environments. | `false` |
49+
| `DAPR_GRPC_TLS_CA_PATH` | Path to the CA certificate file. This is used for TLS connections to servers with self-signed certificates. | `null` |
50+
| `DAPR_GRPC_TLS_CERT_PATH` | Path to the TLS certificate file for client authentication. | `null` |
51+
| `DAPR_GRPC_TLS_KEY_PATH` | Path to the TLS private key file for client authentication. | `null` |
52+
53+
#### Keepalive Settings
54+
Configure gRPC keepalive behavior using these environment variables:
55+
56+
| Environment Variable | Description | Default |
57+
|---------------------|-------------|---------|
58+
| `DAPR_GRPC_ENABLE_KEEP_ALIVE` | Whether to enable gRPC keepalive | `false` |
59+
| `DAPR_GRPC_KEEP_ALIVE_TIME_SECONDS` | gRPC keepalive time in seconds | `10` |
60+
| `DAPR_GRPC_KEEP_ALIVE_TIMEOUT_SECONDS` | gRPC keepalive timeout in seconds | `5` |
61+
| `DAPR_GRPC_KEEP_ALIVE_WITHOUT_CALLS` | Whether to keep gRPC connection alive without calls | `true` |
62+
63+
### HTTP Client Configuration
64+
65+
These properties control the behavior of the HTTP client used for communication with the Dapr sidecar:
66+
67+
| Environment Variable | Description | Default |
68+
|---------------------|-------------|---------|
69+
| `DAPR_HTTP_CLIENT_READ_TIMEOUT_SECONDS` | Timeout in seconds for HTTP client read operations. This is the maximum time to wait for a response from the Dapr sidecar. | `60` |
70+
| `DAPR_HTTP_CLIENT_MAX_REQUESTS` | Maximum number of concurrent HTTP requests that can be executed. Above this limit, requests will queue in memory waiting for running calls to complete. | `1024` |
71+
| `DAPR_HTTP_CLIENT_MAX_IDLE_CONNECTIONS` | Maximum number of idle connections in the HTTP connection pool. This is the maximum number of connections that can remain idle in the pool. | `128` |
72+
73+
### API Configuration
74+
75+
These properties control the behavior of API calls made through the SDK:
76+
77+
| Environment Variable | Description | Default |
78+
|---------------------|-------------|---------|
79+
| `DAPR_API_MAX_RETRIES` | Maximum number of retries for retriable exceptions when making API calls to the Dapr sidecar | `0` |
80+
| `DAPR_API_TIMEOUT_MILLISECONDS` | Timeout in milliseconds for API calls to the Dapr sidecar. A value of 0 means no timeout. | `0` |
81+
82+
### String Encoding
83+
84+
| Environment Variable | Description | Default |
85+
|---------------------|-------------|---------|
86+
| `DAPR_STRING_CHARSET` | Character set used for string encoding/decoding in the SDK. Must be a valid Java charset name. | `UTF-8` |
87+
88+
### System Properties
89+
90+
All environment variables can be set as system properties using the `-D` flag. Here is the complete list of available system properties:
91+
92+
| System Property | Description | Default |
93+
|----------------|-------------|---------|
94+
| `dapr.sidecar.ip` | IP address for the Dapr sidecar | `localhost` |
95+
| `dapr.http.port` | HTTP port for the Dapr sidecar | `3500` |
96+
| `dapr.grpc.port` | gRPC port for the Dapr sidecar | `50001` |
97+
| `dapr.grpc.tls.cert.path` | Path to the gRPC TLS certificate | `null` |
98+
| `dapr.grpc.tls.key.path` | Path to the gRPC TLS key | `null` |
99+
| `dapr.grpc.tls.ca.path` | Path to the gRPC TLS CA certificate | `null` |
100+
| `dapr.grpc.tls.insecure` | Whether to use insecure TLS mode | `false` |
101+
| `dapr.grpc.endpoint` | gRPC endpoint for remote sidecar | `null` |
102+
| `dapr.grpc.enable.keep.alive` | Whether to enable gRPC keepalive | `false` |
103+
| `dapr.grpc.keep.alive.time.seconds` | gRPC keepalive time in seconds | `10` |
104+
| `dapr.grpc.keep.alive.timeout.seconds` | gRPC keepalive timeout in seconds | `5` |
105+
| `dapr.grpc.keep.alive.without.calls` | Whether to keep gRPC connection alive without calls | `true` |
106+
| `dapr.http.endpoint` | HTTP endpoint for remote sidecar | `null` |
107+
| `dapr.api.maxRetries` | Maximum number of retries for API calls | `0` |
108+
| `dapr.api.timeoutMilliseconds` | Timeout for API calls in milliseconds | `0` |
109+
| `dapr.api.token` | API token for authentication | `null` |
110+
| `dapr.string.charset` | String encoding used in the SDK | `UTF-8` |
111+
| `dapr.http.client.readTimeoutSeconds` | Timeout in seconds for HTTP client reads | `60` |
112+
| `dapr.http.client.maxRequests` | Maximum number of concurrent HTTP requests | `1024` |
113+
| `dapr.http.client.maxIdleConnections` | Maximum number of idle HTTP connections | `128` |
114+
115+
## Property Resolution Order
116+
117+
Properties are resolved in the following order:
118+
1. Override values (if provided when creating a Properties instance)
119+
2. System properties (set via `-D`)
120+
3. Environment variables
121+
4. Default values
122+
123+
The SDK checks each source in order. If a value is invalid for the property type (e.g., non-numeric for a numeric property), the SDK will log a warning and try the next source. For example:
124+
125+
```bash
126+
# Invalid boolean value - will be ignored
127+
java -Ddapr.grpc.enable.keep.alive=not-a-boolean -jar myapp.jar
128+
129+
# Valid boolean value - will be used
130+
export DAPR_GRPC_ENABLE_KEEP_ALIVE=false
131+
```
132+
133+
In this case, the environment variable is used because the system property value is invalid. However, if both values are valid, the system property takes precedence:
134+
135+
```bash
136+
# Valid boolean value - will be used
137+
java -Ddapr.grpc.enable.keep.alive=true -jar myapp.jar
138+
139+
# Valid boolean value - will be ignored
140+
export DAPR_GRPC_ENABLE_KEEP_ALIVE=false
141+
```
142+
143+
Override values can be set using the `DaprClientBuilder` in two ways:
144+
145+
1. Using individual property overrides (recommended for most cases):
146+
```java
147+
import io.dapr.config.Properties;
148+
149+
// Set a single property override
150+
DaprClient client = new DaprClientBuilder()
151+
.withPropertyOverride(Properties.GRPC_ENABLE_KEEP_ALIVE, "true")
152+
.build();
153+
154+
// Or set multiple property overrides
155+
DaprClient client = new DaprClientBuilder()
156+
.withPropertyOverride(Properties.GRPC_ENABLE_KEEP_ALIVE, "true")
157+
.withPropertyOverride(Properties.HTTP_CLIENT_READ_TIMEOUT_SECONDS, "120")
158+
.build();
159+
```
160+
161+
2. Using a Properties instance (useful when you have many properties to set at once):
162+
```java
163+
// Create a map of property overrides
164+
Map<String, String> overrides = new HashMap<>();
165+
overrides.put("dapr.grpc.enable.keep.alive", "true");
166+
overrides.put("dapr.http.client.readTimeoutSeconds", "120");
167+
168+
// Create a Properties instance with overrides
169+
Properties properties = new Properties(overrides);
170+
171+
// Use these properties when creating a client
172+
DaprClient client = new DaprClientBuilder()
173+
.withProperties(properties)
174+
.build();
175+
```
176+
177+
For most use cases, you'll use system properties or environment variables. Override values are primarily used when you need different property values for different instances of the SDK in the same application.
178+
179+
## Proxy Configuration
180+
181+
You can configure proxy settings for your Java application using system properties. These are standard Java system properties that are part of Java's networking layer (`java.net` package), not specific to Dapr. They are used by Java's networking stack, including the HTTP client that Dapr's SDK uses.
182+
183+
For detailed information about Java's proxy configuration, including all available properties and their usage, see the [Java Networking Properties documentation](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/net/doc-files/net-properties.html).
184+
185+
186+
For example, here's how to configure a proxy:
187+
188+
```bash
189+
# Configure HTTP proxy - replace with your actual proxy server details
190+
java -Dhttp.proxyHost=your-proxy-server.com -Dhttp.proxyPort=8080 -jar myapp.jar
191+
192+
# Configure HTTPS proxy - replace with your actual proxy server details
193+
java -Dhttps.proxyHost=your-proxy-server.com -Dhttps.proxyPort=8443 -jar myapp.jar
194+
```
195+
196+
Replace `your-proxy-server.com` with your actual proxy server hostname or IP address, and adjust the port numbers to match your proxy server configuration.
197+
198+
These proxy settings will affect all HTTP/HTTPS connections made by your Java application, including connections to the Dapr sidecar.

examples/src/main/java/io/dapr/examples/DaprApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
public class DaprApplication {
2424

2525
/**
26-
* Starts Dapr's callback in a given port and specified protocal.
26+
* Starts Dapr's callback in a given port and specified protocol.
2727
*
2828
* @param port Port to listen to.
2929
* @param protocal select Http or gRPC to run.

sdk-actors/src/main/java/io/dapr/actors/client/ActorProxyImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ActorProxyImpl implements ActorProxy, InvocationHandler {
4242
private final String actorType;
4343

4444
/**
45-
* Serializer/deserialzier to exchange message for Actors.
45+
* Serializer/deserializer to exchange message for Actors.
4646
*/
4747
private final DaprObjectSerializer serializer;
4848

sdk-tests/src/test/java/io/dapr/it/actors/ActorStateIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void writeReadState() throws Exception {
5555
new ActorProxyBuilder(actorType, ActorProxy.class, deferClose(run.newActorClient()));
5656
ActorProxy proxy = proxyBuilder.build(actorId);
5757

58-
// wating for actor to be activated
58+
// waiting for actor to be activated
5959
Thread.sleep(5000);
6060

6161
// Validate conditional read works.

sdk-tests/src/test/java/io/dapr/it/state/AbstractStateClientIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ public void saveUpdateAndGetStateWithEtag() {
331331

332332

333333
response = daprClient.getState(STATE_STORE_NAME, new State<>(stateKey, (MyData) null, null), MyData.class);
334-
//retrive the data wihout any etag
334+
//retrieve the data without any etag
335335
myDataResponse = response.block();
336336

337337
//review that state value changes
@@ -509,7 +509,7 @@ public void saveAndDeleteStateWithWrongEtag() {
509509
public void saveUpdateAndGetStateWithEtagAndStateOptionsFirstWrite() {
510510
final String stateKey = "keyToBeUpdatedWithEtagAndOptions";
511511

512-
//create option with concurrency with first writte and consistency of strong
512+
//create option with concurrency with first write and consistency of strong
513513
StateOptions stateOptions = new StateOptions(StateOptions.Consistency.STRONG,
514514
StateOptions.Concurrency.FIRST_WRITE);
515515

@@ -571,7 +571,7 @@ public void saveUpdateAndGetStateWithEtagAndStateOptionsFirstWrite() {
571571
public void saveUpdateAndGetStateWithEtagAndStateOptionsLastWrite() {
572572
final String stateKey = "keyToBeUpdatedWithEtagAndOptions";
573573

574-
//create option with concurrency with first writte and consistency of strong
574+
//create option with concurrency with first write and consistency of strong
575575
StateOptions stateOptions = new StateOptions(StateOptions.Consistency.STRONG, StateOptions.Concurrency.LAST_WRITE);
576576

577577
//create dapr client
@@ -599,7 +599,7 @@ public void saveUpdateAndGetStateWithEtagAndStateOptionsLastWrite() {
599599
assertEquals("data in property A", myDataResponse.getValue().getPropertyA());
600600
assertEquals("data in property B", myDataResponse.getValue().getPropertyB());
601601

602-
//change data to be udpated
602+
//change data to be updated
603603
data.setPropertyA("data in property A2");
604604
data.setPropertyB("data in property B2");
605605
//create deferred action to update the action with options

sdk/src/main/java/io/dapr/client/DaprClientBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public DaprPreviewClient buildPreviewClient() {
156156
}
157157

158158
/**
159-
* Creates an instance of the GPRC Client.
159+
* Creates an instance of the GRPC Client.
160160
*
161161
* @return the GRPC Client.
162162
* @throws java.lang.IllegalStateException if either host is missing or if port is missing or a negative number.

sdk/src/main/java/io/dapr/client/domain/State.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import java.util.Map;
1818

1919
/**
20-
* This class reprent what a State is.
20+
* This class represents what a State is.
2121
*
2222
* @param <T> The type of the value of the sate
2323
*/

sdk/src/main/java/io/dapr/config/Properties.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,50 @@ public class Properties {
145145
"DAPR_GRPC_ENDPOINT",
146146
null);
147147

148+
/**
149+
* GRPC enable keep alive.
150+
* Environment variable: DAPR_GRPC_ENABLE_KEEP_ALIVE
151+
* System property: dapr.grpc.enable.keep.alive
152+
* Default: false
153+
*/
154+
public static final Property<Boolean> GRPC_ENABLE_KEEP_ALIVE = new BooleanProperty(
155+
"dapr.grpc.enable.keep.alive",
156+
"DAPR_GRPC_ENABLE_KEEP_ALIVE",
157+
false);
158+
159+
/**
160+
* GRPC keep alive time in seconds.
161+
* Environment variable: DAPR_GRPC_KEEP_ALIVE_TIME_SECONDS
162+
* System property: dapr.grpc.keep.alive.time.seconds
163+
* Default: 10 seconds
164+
*/
165+
public static final Property<Duration> GRPC_KEEP_ALIVE_TIME_SECONDS = new SecondsDurationProperty(
166+
"dapr.grpc.keep.alive.time.seconds",
167+
"DAPR_GRPC_KEEP_ALIVE_TIME_SECONDS",
168+
Duration.ofSeconds(10));
169+
170+
/**
171+
* GRPC keep alive timeout in seconds.
172+
* Environment variable: DAPR_GRPC_KEEP_ALIVE_TIMEOUT_SECONDS
173+
* System property: dapr.grpc.keep.alive.timeout.seconds
174+
* Default: 5 seconds
175+
*/
176+
public static final Property<Duration> GRPC_KEEP_ALIVE_TIMEOUT_SECONDS = new SecondsDurationProperty(
177+
"dapr.grpc.keep.alive.timeout.seconds",
178+
"DAPR_GRPC_KEEP_ALIVE_TIMEOUT_SECONDS",
179+
Duration.ofSeconds(5));
180+
181+
/**
182+
* GRPC keep alive without calls.
183+
* Environment variable: DAPR_GRPC_KEEP_ALIVE_WITHOUT_CALLS
184+
* System property: dapr.grpc.keep.alive.without.calls
185+
* Default: true
186+
*/
187+
public static final Property<Boolean> GRPC_KEEP_ALIVE_WITHOUT_CALLS = new BooleanProperty(
188+
"dapr.grpc.keep.alive.without.calls",
189+
"DAPR_GRPC_KEEP_ALIVE_WITHOUT_CALLS",
190+
true);
191+
148192
/**
149193
* GRPC endpoint for remote sidecar connectivity.
150194
*/

0 commit comments

Comments
 (0)