Skip to content

Commit c30f537

Browse files
authored
Merge branch 'dapr:master' into master
2 parents 0b3e757 + a99d286 commit c30f537

File tree

62 files changed

+2744
-125
lines changed

Some content is hidden

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

62 files changed

+2744
-125
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ jobs:
121121
env:
122122
DOCKER_HOST: ${{steps.setup_docker.outputs.sock}}
123123
- name: Codecov
124-
uses: codecov/codecov-action@v5.4.2
124+
uses: codecov/codecov-action@v5.4.3
125125
- name: Install jars
126126
run: ./mvnw install -q -B -DskipTests
127127
- name: Integration tests using spring boot version ${{ matrix.spring-boot-version }}

.github/workflows/fossa.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ jobs:
3535
uses: actions/checkout@v4
3636

3737
- name: "Run FOSSA Scan"
38-
uses: fossas/fossa-action@v1.6.0 # Use a specific version if locking is preferred
38+
uses: fossas/fossa-action@v1.7.0 # Use a specific version if locking is preferred
3939
with:
4040
api-key: ${{ env.FOSSA_API_KEY }}
4141

4242
- name: "Run FOSSA Test"
43-
uses: fossas/fossa-action@v1.6.0 # Use a specific version if locking is preferred
43+
uses: fossas/fossa-action@v1.7.0 # Use a specific version if locking is preferred
4444
with:
4545
api-key: ${{ env.FOSSA_API_KEY }}
4646
run-tests: true

.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}}

dapr-spring/dapr-spring-boot-autoconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/PropertiesDaprConnectionDetails.java renamed to dapr-spring/dapr-spring-boot-autoconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/ClientPropertiesDaprConnectionDetails.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
package io.dapr.spring.boot.autoconfigure.client;
1515

16-
class PropertiesDaprConnectionDetails implements DaprConnectionDetails {
16+
public class ClientPropertiesDaprConnectionDetails implements DaprConnectionDetails {
1717

1818
private final DaprClientProperties daprClientProperties;
1919

20-
public PropertiesDaprConnectionDetails(DaprClientProperties daprClientProperties) {
20+
public ClientPropertiesDaprConnectionDetails(DaprClientProperties daprClientProperties) {
2121
this.daprClientProperties = daprClientProperties;
2222
}
2323

dapr-spring/dapr-spring-boot-autoconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/DaprClientAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class DaprClientAutoConfiguration {
3737
@Bean
3838
@ConditionalOnMissingBean(DaprConnectionDetails.class)
3939
DaprConnectionDetails daprConnectionDetails(DaprClientProperties properties) {
40-
return new PropertiesDaprConnectionDetails(properties);
40+
return new ClientPropertiesDaprConnectionDetails(properties);
4141
}
4242

4343
@Bean

dapr-spring/dapr-spring-boot-autoconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/DaprConnectionDetails.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
import org.springframework.boot.autoconfigure.service.connection.ConnectionDetails;
1717

1818
public interface DaprConnectionDetails extends ConnectionDetails {
19+
1920
String getHttpEndpoint();
2021

2122
String getGrpcEndpoint();
2223

2324
Integer getHttpPort();
2425

2526
Integer getGrpcPort();
27+
2628
}

dapr-spring/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<maven.compiler.release>11</maven.compiler.release>
3535
<testcontainers.version>1.19.8</testcontainers.version>
3636
<junit.version>5.10.2</junit.version>
37+
<logback-core.version>1.4.14</logback-core.version>
3738
</properties>
3839

3940
<dependencyManagement>
@@ -70,6 +71,11 @@
7071
<artifactId>junit-jupiter</artifactId>
7172
<version>${testcontainers.version}</version>
7273
</dependency>
74+
<dependency>
75+
<groupId>ch.qos.logback</groupId>
76+
<artifactId>logback-core</artifactId>
77+
<version>${logback-core.version}</version>
78+
</dependency>
7379
</dependencies>
7480
</dependencyManagement>
7581

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.

daprdocs/content/en/java-sdk-docs/spring-boot/_index.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,37 @@ description: How to get started with Dapr and Spring Boot
88

99
By combining Dapr and Spring Boot, we can create infrastructure independent Java applications that can be deployed across different environments, supporting a wide range of on-premises and cloud provider services.
1010

11-
First, we will start with a simple integration covering the `DaprClient` and the [Testcontainers](https://testcontainers.com/) integration, to then use Spring and Spring Boot mechanisms and programming model to leverage the Dapr APIs under the hood. This help teams to remove dependencies such as clients and drivers required to connect to environment specific infrastructure (databases, key-value stores, message brokers, configuration/secret stores, etc.)
11+
First, we will start with a simple integration covering the `DaprClient` and the [Testcontainers](https://testcontainers.com/) integration, to then use Spring and Spring Boot mechanisms and programming model to leverage the Dapr APIs under the hood. This helps teams to remove dependencies such as clients and drivers required to connect to environment-specific infrastructure (databases, key-value stores, message brokers, configuration/secret stores, etc)
1212

1313
{{% alert title="Note" color="primary" %}}
14-
The Spring Boot integration explained in this page is still alpha, hence most artifacts are labeled with 0.13.0.
14+
The Spring Boot integration requires Spring Boot 3.x+ to work. This will not work with Spring Boot 2.x.
15+
The Spring Boot integration remains in alpha. We need your help and feedback to graduate it.
16+
Please join the [#java-sdk discord channel](https://discord.com/channels/778680217417809931/778749797242765342) discussion or open issues in the [dapr/java-sdk](https://github.com/dapr/java-sdk/issues).
1517

1618
{{% /alert %}}
1719

1820

1921
## Adding the Dapr and Spring Boot integration to your project
2022

21-
If you already have a Spring Boot application (Spring Boot 3.x+), you can directly add the following dependencies to your project:
22-
23+
If you already have a Spring Boot application, you can directly add the following dependencies to your project:
2324

2425
```
2526
<dependency>
2627
<groupId>io.dapr.spring</groupId>
2728
<artifactId>dapr-spring-boot-starter</artifactId>
28-
<version>0.14.1</version>
29+
<version>0.x.x</version> // see below for the latest versions
2930
</dependency>
3031
<dependency>
3132
<groupId>io.dapr.spring</groupId>
3233
<artifactId>dapr-spring-boot-starter-test</artifactId>
33-
<version>0.14.1</version>
34+
<version>0.x.x</version> // see below for the latest versions
3435
<scope>test</scope>
3536
</dependency>
3637
```
3738

38-
By adding these dependencies you can:
39+
You can find the [latest released version here](https://central.sonatype.com/artifact/io.dapr.spring/dapr-spring-boot-starter).
40+
41+
By adding these dependencies, you can:
3942
- Autowire a `DaprClient` to use inside your applications
4043
- Use the Spring Data and Messaging abstractions and programming model that uses the Dapr APIs under the hood
4144
- Improve your inner-development loop by relying on [Testcontainers](https://testcontainers.com/) to bootstrap Dapr Control plane services and default components

0 commit comments

Comments
 (0)