Skip to content

Commit fdbc3c6

Browse files
authored
Merge branch 'main' into otel-trace-prop
Signed-off-by: salaboy <[email protected]>
2 parents 0becec9 + 4ffeb04 commit fdbc3c6

File tree

25 files changed

+510
-110
lines changed

25 files changed

+510
-110
lines changed

.github/workflows/build-validation.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,6 @@ jobs:
2525
uses: actions/setup-java@v2
2626
with:
2727
java-version: '11'
28-
distribution: 'microsoft'
29-
30-
- name: set JDK_11 environment variable test compiling and running
31-
env:
32-
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
33-
run: echo ::set-env name=JDK_11::$(echo $JAVA_HOME)
34-
35-
- name: Set up JDK 8
36-
uses: actions/setup-java@v2
37-
with:
38-
java-version: '8'
3928
distribution: 'temurin'
4029

4130
- name: Setup Gradle
@@ -57,7 +46,6 @@ jobs:
5746

5847
- name: Run Unit Tests with Gradle
5948
run: |
60-
export JAVA_HOME=$JDK_11
6149
./gradlew clean test || echo "UNIT_TEST_FAILED=true" >> $GITHUB_ENV
6250
continue-on-error: true
6351

.github/workflows/release.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,7 @@ jobs:
3131
java-version: '11'
3232
distribution: 'microsoft'
3333

34-
- name: set JDK_11 environment variable test compiling and running
35-
env:
36-
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
37-
run: echo ::set-env name=JDK_11::$(echo $JAVA_HOME)
3834

39-
- name: Set up JDK 8
40-
uses: actions/setup-java@v2
41-
with:
42-
java-version: '8'
43-
distribution: 'temurin'
4435

4536
- name: Setup Gradle
4637
uses: gradle/gradle-build-action@v2
@@ -61,7 +52,6 @@ jobs:
6152

6253
- name: Run Unit Tests with Gradle
6354
run: |
64-
export JAVA_HOME=$JDK_11
6555
./gradlew clean test || echo "UNIT_TEST_FAILED=true" >> $GITHUB_ENV
6656
continue-on-error: true
6757

CONTRIBUTING.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,52 @@
1+
Verify Compilation:
2+
```shell
3+
./gradlew compileJava
4+
```
5+
16
Build & test:
27

38
```shell
49
./gradlew build
5-
```
10+
```
11+
12+
## Verify Build Components
13+
14+
To ensure all build components work correctly after making changes:
15+
16+
```shell
17+
# Build without tests
18+
./gradlew build -x test
19+
20+
# Run unit tests
21+
./gradlew test
22+
23+
# Run SpotBugs
24+
./gradlew spotbugsMain spotbugsTest
25+
```
26+
27+
## Updating Protobuf Definitions
28+
29+
When updating the protobuf definitions in `internal/durabletask-protobuf/protos/orchestrator_service.proto`:
30+
31+
1. Manually copy the updated protobuf file from dapr/durabletask-protobuf
32+
2. Update the commit hash in `internal/durabletask-protobuf/PROTO_SOURCE_COMMIT_HASH` to reflect the new commit
33+
3. Regenerate the Java classes from the protobuf definitions:
34+
35+
```shell
36+
./gradlew generateProto
37+
```
38+
39+
## Test locally from dapr/java-sdk
40+
41+
```shell
42+
./gradlew publishToMavenLocal
43+
```
44+
45+
or simply `./gradlew build publishToMavenLocal`
46+
47+
Check if it was released locally with:
48+
```shell
49+
ls ~/.m2/repository/io/dapr/durabletask-client/
50+
```
51+
52+
Then update the durabletask-client in the java-sdk pom.xml file to the newest version you released locally.

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# Durable Task Client SDK for Java
22

3-
[![Build](https://github.com/microsoft/durabletask-java/actions/workflows/build-validation.yml/badge.svg)](https://github.com/microsoft/durabletask-java/actions/workflows/build-validation.yml)
3+
[![Build](https://github.com/dapr/durabletask-java/actions/workflows/build-validation.yml/badge.svg)](https://github.com/dapr/durabletask-java/actions/workflows/build-validation.yml)
44
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
55

66
This repo contains the Java SDK for the Durable Task Framework as well as classes and annotations to support running [Azure Durable Functions](https://docs.microsoft.com/azure/azure-functions/durable/durable-functions-overview?tabs=java) for Java. With this SDK, you can define, schedule, and manage durable orchestrations using ordinary Java code.
77

8+
## Requirements
9+
10+
- **Java 11 or higher** - This SDK requires Java 11 as the minimum version
11+
- **Gradle** - The project uses [Gradle 7.6.4](gradle/wrapper/gradle-wrapper.properties)
12+
813
### Simple, fault-tolerant sequences
914

1015
```java
@@ -78,8 +83,7 @@ The following packages are produced from this repo.
7883

7984
| Package | Latest version |
8085
| - | - |
81-
| Durable Task - Client | [![Maven Central](https://img.shields.io/maven-central/v/com.microsoft/durabletask-client?label=durabletask-client)](https://mvnrepository.com/artifact/com.microsoft/durabletask-client/1.0.0) |
82-
| Durable Task - Azure Functions | [![Maven Central](https://img.shields.io/maven-central/v/com.microsoft/durabletask-azure-functions?label=durabletask-azure-functions)](https://mvnrepository.com/artifact/com.microsoft/durabletask-azure-functions/1.0.1) |
86+
| Durable Task - Client | [![Maven Central](https://img.shields.io/maven-central/v/io.dapr/durabletask-client?label=durabletask-client)](https://mvnrepository.com/artifact/io.dapr/durabletask-client/1.5.7) |
8387

8488
## Getting started with Azure Functions
8589

azurefunctions/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ In this article, you follow steps to create and run a simple azure durable funct
66

77
The following are the requirements for you local environment:
88

9-
- The Java Developer Kit, version 8 or 11, is required. Between the two, JDK 11 is recommended.
9+
- The Java Developer Kit, version 11 or higher, is required.
1010
- The `JAVA_HOME` environment variable must be set to the install location of the correct version of the JDK.
1111
- [Apache Maven](https://maven.apache.org/), version 3.0 or above for azure function app creation, is required for using automatic project creation tools.
1212
- If Maven isn't your preferred development tool, check out our similar tutorials to [create a function app](https://docs.microsoft.com/en-us/azure/azure-functions/create-first-function-cli-java?tabs=bash%2Cazure-cli%2Cbrowser). This README also contains instructions for [Gradle](https://gradle.org/).

azurefunctions/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ dependencies {
2424
compileOnly "com.microsoft.azure.functions:azure-functions-java-spi:1.0.0"
2525
}
2626

27-
sourceCompatibility = JavaVersion.VERSION_1_8
28-
targetCompatibility = JavaVersion.VERSION_1_8
27+
sourceCompatibility = JavaVersion.VERSION_11
28+
targetCompatibility = JavaVersion.VERSION_11
2929

3030
publishing {
3131
repositories {

azuremanaged/build.gradle

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,13 @@ dependencies {
4949
}
5050

5151
compileJava {
52-
sourceCompatibility = JavaVersion.VERSION_1_8
53-
targetCompatibility = JavaVersion.VERSION_1_8
52+
sourceCompatibility = JavaVersion.VERSION_11
53+
targetCompatibility = JavaVersion.VERSION_11
5454
}
5555

5656
compileTestJava {
5757
sourceCompatibility = JavaVersion.VERSION_11
5858
targetCompatibility = JavaVersion.VERSION_11
59-
options.fork = true
60-
options.forkOptions.executable = "${PATH_TO_TEST_JAVA_RUNTIME}/bin/javac"
6159
}
6260

6361
test {

client/build.gradle

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ plugins {
1111
}
1212

1313
group 'io.dapr'
14-
version = '1.5.8-SNAPSHOT'
14+
version = '1.5.8'
1515
archivesBaseName = 'durabletask-client'
1616

1717
def grpcVersion = '1.69.0'
1818
def protocVersion = '3.25.5'
1919
def jacksonVersion = '2.15.3'
20+
2021
def otelVersion = '1.51.0'
2122
def micrometerVersion = '1.5.1'
2223

@@ -25,11 +26,15 @@ def micrometerVersion = '1.5.1'
2526
// Example for Windows: C:/Program Files/Java/openjdk-11.0.12_7/
2627
def PATH_TO_TEST_JAVA_RUNTIME = System.env.JDK_11 ?: System.getProperty("java.home")
2728

29+
// Java 11 is now the minimum required version for both compilation and testing
30+
31+
2832
dependencies {
2933

3034
// https://github.com/grpc/grpc-java#download
3135
implementation "io.grpc:grpc-protobuf:${grpcVersion}"
3236
implementation "io.grpc:grpc-stub:${grpcVersion}"
37+
implementation 'com.google.protobuf:protobuf-java:3.25.5'
3338
runtimeOnly "io.grpc:grpc-netty-shaded:${grpcVersion}"
3439

3540
implementation "io.opentelemetry:opentelemetry-api:${otelVersion}"
@@ -50,49 +55,59 @@ dependencies {
5055

5156
// Netty dependencies for TLS
5257
implementation "io.grpc:grpc-netty-shaded:${grpcVersion}"
53-
implementation "io.netty:netty-handler:4.1.94.Final"
58+
implementation 'io.netty:netty-handler:4.1.119.Final'
5459
implementation "io.netty:netty-tcnative-boringssl-static:2.0.59.Final"
5560

5661
// Add Netty dependencies to test classpath
5762
testImplementation "io.grpc:grpc-netty-shaded:${grpcVersion}"
58-
testImplementation "io.netty:netty-handler:4.1.94.Final"
63+
testImplementation 'io.netty:netty-handler:4.1.119.Final'
5964
testImplementation "io.netty:netty-tcnative-boringssl-static:2.0.59.Final"
6065

6166
testImplementation 'org.bouncycastle:bcprov-jdk15on:1.70'
6267
testImplementation 'org.bouncycastle:bcpkix-jdk15on:1.70'
6368
}
6469

6570
compileJava {
66-
sourceCompatibility = JavaVersion.VERSION_1_8
67-
targetCompatibility = JavaVersion.VERSION_1_8
71+
sourceCompatibility = JavaVersion.VERSION_11
72+
targetCompatibility = JavaVersion.VERSION_11
6873
}
6974
compileTestJava {
7075
sourceCompatibility = JavaVersion.VERSION_11
7176
targetCompatibility = JavaVersion.VERSION_11
72-
options.fork = true
73-
options.forkOptions.executable = "${PATH_TO_TEST_JAVA_RUNTIME}/bin/javac"
7477
}
7578

7679
task downloadProtoFiles {
7780
ext.branch = project.hasProperty('protoBranch') ? project.protoBranch : 'main'
7881

7982
doLast {
8083
def protoDir = file("${rootProject.projectDir}/internal/durabletask-protobuf/protos")
84+
def protoFile = new File(protoDir, 'orchestrator_service.proto')
85+
def commitHashFile = new File("${rootProject.projectDir}/internal/durabletask-protobuf/PROTO_SOURCE_COMMIT_HASH")
8186
protoDir.mkdirs()
8287

8388
// Download the proto file
8489
new URL("https://raw.githubusercontent.com/dapr/durabletask-protobuf/${ext.branch}/protos/orchestrator_service.proto")
8590
.withInputStream { i ->
86-
new File(protoDir, 'orchestrator_service.proto').withOutputStream { it << i }
91+
protoFile.withOutputStream { it << i }
8792
}
88-
89-
// Get and save the commit hash
90-
def commitHashFile = new File("${rootProject.projectDir}/internal/durabletask-protobuf/PROTO_SOURCE_COMMIT_HASH")
91-
def commitApiUrl = new URL("https://api.github.com/repos/dapr/durabletask-protobuf/commits?path=protos/orchestrator_service.proto&sha=${ext.branch}&per_page=1")
92-
def connection = commitApiUrl.openConnection()
93-
connection.setRequestProperty('Accept', 'application/vnd.github.v3+json')
94-
def commitHash = new groovy.json.JsonSlurper().parse(connection.inputStream)[0].sha
95-
commitHashFile.text = commitHash
93+
94+
try {
95+
def commitApiUrl = new URL("https://api.github.com/repos/dapr/durabletask-protobuf/commits?path=protos/orchestrator_service.proto&sha=${ext.branch}&per_page=1")
96+
def connection = commitApiUrl.openConnection()
97+
connection.setRequestProperty('Accept', 'application/vnd.github.v3+json')
98+
connection.setRequestProperty('User-Agent', 'durabletask-java-build')
99+
100+
// Add GitHub token if available (automatically provided in GitHub Actions)
101+
if (System.env.GITHUB_TOKEN) {
102+
connection.setRequestProperty('Authorization', "token ${System.env.GITHUB_TOKEN}")
103+
}
104+
105+
def commitHash = new groovy.json.JsonSlurper().parse(connection.inputStream)[0].sha
106+
commitHashFile.text = commitHash
107+
logger.info("Successfully updated proto commit hash: ${commitHash}")
108+
} catch (Exception e) {
109+
logger.error("Failed to fetch commit hash from GitHub API: ${e.message}")
110+
}
96111
}
97112
}
98113

@@ -121,10 +136,6 @@ sourceSets {
121136
}
122137
}
123138

124-
tasks.withType(Test) {
125-
executable = new File("${PATH_TO_TEST_JAVA_RUNTIME}", 'bin/java')
126-
}
127-
128139
test {
129140
useJUnitPlatform {
130141
// Skip tests tagged as "integration" since those are slower
@@ -214,6 +225,10 @@ java {
214225
withJavadocJar()
215226
}
216227

228+
tasks.named('sourcesJar').configure {
229+
dependsOn tasks.named('generateProto')
230+
}
231+
217232
spotbugs {
218233
toolVersion = '4.9.2'
219234
effort = 'max'

client/src/main/java/io/dapr/durabletask/DurableTaskGrpcWorker.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public final class DurableTaskGrpcWorker implements AutoCloseable {
4343
private final DataConverter dataConverter;
4444
private final Duration maximumTimerInterval;
4545
private final ExecutorService workerPool;
46+
private final String appId; // App ID for cross-app routing
4647

4748
private final TaskHubSidecarServiceBlockingStub sidecarClient;
4849
private final boolean isExecutorServiceManaged;
@@ -53,6 +54,7 @@ public final class DurableTaskGrpcWorker implements AutoCloseable {
5354
DurableTaskGrpcWorker(DurableTaskGrpcWorkerBuilder builder) {
5455
this.orchestrationFactories.putAll(builder.orchestrationFactories);
5556
this.activityFactories.putAll(builder.activityFactories);
57+
this.appId = builder.appId;
5658

5759
Channel sidecarGrpcChannel;
5860
if (builder.channel != null) {
@@ -137,7 +139,8 @@ public void startAndBlock() {
137139
this.orchestrationFactories,
138140
this.dataConverter,
139141
this.maximumTimerInterval,
140-
logger);
142+
logger,
143+
this.appId);
141144
TaskActivityExecutor taskActivityExecutor = new TaskActivityExecutor(
142145
this.activityFactories,
143146
this.dataConverter,
@@ -152,6 +155,9 @@ public void startAndBlock() {
152155
RequestCase requestType = workItem.getRequestCase();
153156
if (requestType == RequestCase.ORCHESTRATORREQUEST) {
154157
OrchestratorRequest orchestratorRequest = workItem.getOrchestratorRequest();
158+
logger.log(Level.FINEST,
159+
String.format("Processing orchestrator request for instance: {0}",
160+
orchestratorRequest.getInstanceId()));
155161

156162
// TODO: Error handling
157163
this.workerPool.submit(() -> {
@@ -168,6 +174,12 @@ public void startAndBlock() {
168174

169175
try {
170176
interceptors.intercept(this.sidecarClient, Context.root()).completeOrchestratorTask(response);
177+
178+
this.sidecarClient.completeOrchestratorTask(response);
179+
logger.log(Level.FINEST,
180+
"Completed orchestrator request for instance: {0}",
181+
orchestratorRequest.getInstanceId());
182+
171183
} catch (StatusRuntimeException e) {
172184
if (e.getStatus().getCode() == Status.Code.UNAVAILABLE) {
173185
logger.log(Level.WARNING,
@@ -186,8 +198,14 @@ public void startAndBlock() {
186198
});
187199
} else if (requestType == RequestCase.ACTIVITYREQUEST) {
188200
ActivityRequest activityRequest = workItem.getActivityRequest();
201+
logger.log(Level.FINEST,
202+
String.format("Processing activity request: %s for instance: %s}",
203+
activityRequest.getName(),
204+
activityRequest.getOrchestrationInstance().getInstanceId()));
205+
206+
207+
// TODO: Error handling
189208

190-
System.out.println(activityRequest);
191209
this.workerPool.submit(() -> {
192210
String output = null;
193211
TaskFailureDetails failureDetails = null;
@@ -243,7 +261,8 @@ public void startAndBlock() {
243261
} else if (requestType == RequestCase.HEALTHPING) {
244262
// No-op
245263
} else {
246-
logger.log(Level.WARNING, "Received and dropped an unknown '{0}' work-item from the sidecar.",
264+
logger.log(Level.WARNING,
265+
"Received and dropped an unknown '{0}' work-item from the sidecar.",
247266
requestType);
248267
}
249268
}

0 commit comments

Comments
 (0)