Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
Verify Compilation:
```shell
./gradlew compileJava
```

Build & test:

```shell
./gradlew build
```
```

## Updating Protobuf Definitions

When updating the protobuf definitions in `internal/durabletask-protobuf/protos/orchestrator_service.proto`:

1. Manually copy the updated protobuf file from dapr/durabletask-protobuf
2. Update the commit hash in `internal/durabletask-protobuf/PROTO_SOURCE_COMMIT_HASH` to reflect the new commit
3. Regenerate the Java classes from the protobuf definitions:

```shell
./gradlew generateProto
```

## Test locally from dapr/java-sdk

```shell
./gradlew publishToMavenLocal
```

or simply `./gradlew build publishToMavenLocal`

Check if it was released locally with:
```shell
ls ~/.m2/repository/io/dapr/durabletask-client/
```

Then update the durabletask-client in the java-sdk pom.xml file to the newest version you released locally.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Durable Task Client SDK for Java

[![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)
[![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)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

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.
Expand Down Expand Up @@ -78,8 +78,7 @@ The following packages are produced from this repo.

| Package | Latest version |
| - | - |
| 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) |
| 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) |
| 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) |

## Getting started with Azure Functions

Expand Down
12 changes: 8 additions & 4 deletions client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies {
// https://github.com/grpc/grpc-java#download
implementation "io.grpc:grpc-protobuf:${grpcVersion}"
implementation "io.grpc:grpc-stub:${grpcVersion}"
implementation 'com.google.protobuf:protobuf-java:3.25.5'
runtimeOnly "io.grpc:grpc-netty-shaded:${grpcVersion}"

compileOnly "org.apache.tomcat:annotations-api:6.0.53"
Expand All @@ -44,16 +45,15 @@ dependencies {

// Netty dependencies for TLS
implementation "io.grpc:grpc-netty-shaded:${grpcVersion}"
implementation "io.netty:netty-handler:4.1.94.Final"
implementation 'io.netty:netty-handler:4.1.119.Final'
implementation "io.netty:netty-tcnative-boringssl-static:2.0.59.Final"

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

testImplementation 'org.bouncycastle:bcprov-jdk15on:1.70'
testImplementation 'org.bouncycastle:bcpkix-jdk15on:1.70'
testImplementation 'org.bouncycastle:bcprov-jdk15on:1.78'
}

compileJava {
Expand Down Expand Up @@ -208,6 +208,10 @@ java {
withJavadocJar()
}

tasks.named('sourcesJar').configure {
dependsOn tasks.named('generateProto')
}

spotbugs {
toolVersion = '4.9.2'
effort = 'max'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public final class DurableTaskGrpcWorker implements AutoCloseable {
private final DataConverter dataConverter;
private final Duration maximumTimerInterval;
private final ExecutorService workerPool;
private final String appId; // App ID for cross-app routing

private final TaskHubSidecarServiceBlockingStub sidecarClient;
private final boolean isExecutorServiceManaged;
Expand All @@ -45,6 +46,7 @@ public final class DurableTaskGrpcWorker implements AutoCloseable {
DurableTaskGrpcWorker(DurableTaskGrpcWorkerBuilder builder) {
this.orchestrationFactories.putAll(builder.orchestrationFactories);
this.activityFactories.putAll(builder.activityFactories);
this.appId = builder.appId;

Channel sidecarGrpcChannel;
if (builder.channel != null) {
Expand Down Expand Up @@ -128,7 +130,8 @@ public void startAndBlock() {
this.orchestrationFactories,
this.dataConverter,
this.maximumTimerInterval,
logger);
logger,
this.appId);
TaskActivityExecutor taskActivityExecutor = new TaskActivityExecutor(
this.activityFactories,
this.dataConverter,
Expand All @@ -143,6 +146,9 @@ public void startAndBlock() {
RequestCase requestType = workItem.getRequestCase();
if (requestType == RequestCase.ORCHESTRATORREQUEST) {
OrchestratorRequest orchestratorRequest = workItem.getOrchestratorRequest();
logger.log(Level.FINEST,
String.format("Processing orchestrator request for instance: {0}",
orchestratorRequest.getInstanceId()));

// TODO: Error handling
this.workerPool.submit(() -> {
Expand All @@ -159,6 +165,9 @@ public void startAndBlock() {

try {
this.sidecarClient.completeOrchestratorTask(response);
logger.log(Level.FINEST,
"Completed orchestrator request for instance: {0}",
orchestratorRequest.getInstanceId());
} catch (StatusRuntimeException e) {
if (e.getStatus().getCode() == Status.Code.UNAVAILABLE) {
logger.log(Level.WARNING,
Expand All @@ -177,7 +186,12 @@ public void startAndBlock() {
});
} else if (requestType == RequestCase.ACTIVITYREQUEST) {
ActivityRequest activityRequest = workItem.getActivityRequest();
logger.log(Level.FINEST,
String.format("Processing activity request: %s for instance: %s}",
activityRequest.getName(),
activityRequest.getOrchestrationInstance().getInstanceId()));

// TODO: Error handling
this.workerPool.submit(() -> {
String output = null;
TaskFailureDetails failureDetails = null;
Expand Down Expand Up @@ -228,7 +242,8 @@ public void startAndBlock() {
} else if (requestType == RequestCase.HEALTHPING) {
// No-op
} else {
logger.log(Level.WARNING, "Received and dropped an unknown '{0}' work-item from the sidecar.",
logger.log(Level.WARNING,
"Received and dropped an unknown '{0}' work-item from the sidecar.",
requestType);
}
}
Expand Down
Loading
Loading