Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .github/scripts/update_sdk_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ mvn versions:set-property -Dproperty=dapr.sdk.version -DnewVersion=$DAPR_JAVA_SD
# BOMs are standalone (no parent), so versions:set skips them — update explicitly.
mvn versions:set -DnewVersion=$DAPR_JAVA_SDK_VERSION -f sdk-bom/pom.xml
mvn versions:set-property -Dproperty=dapr.sdk.version -DnewVersion=$DAPR_JAVA_SDK_VERSION -f sdk-bom/pom.xml
# Install dapr-sdk-bom locally so dapr-spring-bom's import can resolve when loaded with -f (no reactor).
mvn install -N -DskipTests -f sdk-bom/pom.xml
mvn versions:set -DnewVersion=$DAPR_JAVA_SDK_VERSION -f dapr-spring/dapr-spring-bom/pom.xml
mvn versions:set-property -Dproperty=dapr.sdk.version -DnewVersion=$DAPR_JAVA_SDK_VERSION -f dapr-spring/dapr-spring-bom/pom.xml
mvn versions:set-property -Dproperty=dapr.sdk.alpha.version -DnewVersion=$DAPR_JAVA_SDK_ALPHA_VERSION -f sdk-tests/pom.xml
Expand Down
2 changes: 1 addition & 1 deletion dapr-spring/dapr-spring-6-data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.dapr.spring</groupId>
<artifactId>dapr-spring-parent</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions dapr-spring/dapr-spring-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.dapr.spring</groupId>
<artifactId>dapr-spring-bom</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<packaging>pom</packaging>
<name>dapr-spring-bom</name>
<description>Dapr Spring Bill of Materials (BOM). Import this POM to manage versions
Expand Down Expand Up @@ -45,7 +45,7 @@

<properties>
<gpg.skip>true</gpg.skip>
<dapr.sdk.version>1.18.0-SNAPSHOT</dapr.sdk.version>
<dapr.sdk.version>1.18.0-rc-1</dapr.sdk.version>
</properties>

<build>
Expand Down
2 changes: 1 addition & 1 deletion dapr-spring/dapr-spring-boot-4-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.dapr.spring</groupId>
<artifactId>dapr-spring-parent</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion dapr-spring/dapr-spring-boot-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.dapr.spring</groupId>
<artifactId>dapr-spring-parent</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion dapr-spring/dapr-spring-boot-observation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.dapr.spring</groupId>
<artifactId>dapr-spring-parent</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion dapr-spring/dapr-spring-boot-properties/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.dapr.spring</groupId>
<artifactId>dapr-spring-parent</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.dapr.spring</groupId>
<artifactId>dapr-spring-parent</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.dapr.spring</groupId>
<artifactId>dapr-spring-parent</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.dapr.spring</groupId>
<artifactId>dapr-spring-parent</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.dapr.spring</groupId>
<artifactId>dapr-spring-parent</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion dapr-spring/dapr-spring-boot-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.dapr.spring</groupId>
<artifactId>dapr-spring-parent</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion dapr-spring/dapr-spring-data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.dapr.spring</groupId>
<artifactId>dapr-spring-parent</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion dapr-spring/dapr-spring-messaging/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.dapr.spring</groupId>
<artifactId>dapr-spring-parent</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion dapr-spring/dapr-spring-workflows/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.dapr.spring</groupId>
<artifactId>dapr-spring-parent</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion dapr-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.dapr</groupId>
<artifactId>dapr-sdk-parent</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion durabletask-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.dapr</groupId>
<artifactId>dapr-sdk-parent</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.dapr</groupId>
<artifactId>dapr-sdk-parent</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
39 changes: 39 additions & 0 deletions examples/src/main/java/io/dapr/examples/pubsub/stream/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,38 @@ client.subscribeToTopic(PUBSUB_NAME, topicName, TypeRef.STRING, Map.of("rawPaylo
.blockLast();
```

### Subscription with a Dead-Letter Topic

For workloads that need to forward unprocessable messages to a dead-letter topic,
use the listener-based `subscribeToEvents` overload that accepts a
`deadLetterTopic` argument. When the listener returns `Status.DROP`, the Dapr
runtime publishes the message to the configured dead-letter topic:

```java
var listener = new SubscriptionListener<String>() {
@Override
public Mono<Status> onEvent(CloudEvent<String> event) {
if (shouldRejectMessage(event)) {
return Mono.just(Status.DROP); // forwarded to deadLetterTopicName
}
return Mono.just(Status.SUCCESS);
}

@Override
public void onError(RuntimeException exception) {
System.out.println("Subscriber got exception: " + exception.getMessage());
}
};

try (var subscription = client.subscribeToEvents(
PUBSUB_NAME, topicName, deadLetterTopicName, listener, TypeRef.STRING)) {
subscription.awaitTermination();
}
```

See [SubscriberWithDeadLetter.java](SubscriberWithDeadLetter.java) for a complete example
that consumes the dead-letter topic in the same process.

### Subscription Lifecycle

The examples use `blockLast()` to keep the subscriber running indefinitely. For production use cases requiring explicit subscription lifecycle control, you can use `.subscribe()` which returns a `Disposable` that can be disposed via `disposable.dispose()`.
Expand Down Expand Up @@ -138,6 +170,13 @@ Or run the CloudEvent Subscriber example:
dapr run --resources-path ./components/pubsub --app-id subscriber -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.pubsub.stream.SubscriberCloudEvent
```

Or run the dead-letter Subscriber example, which routes messages whose payload
contains "fail" to a dead-letter topic and consumes both topics:

```bash
dapr run --resources-path ./components/pubsub --app-id subscriber -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.pubsub.stream.SubscriberWithDeadLetter
```

Once the subscriber is running, run the publisher in a new terminal to see the events in the subscriber's side:

<!-- STEP
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Copyright 2024 The Dapr Authors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
limitations under the License.
*/

package io.dapr.examples.pubsub.stream;

import io.dapr.client.DaprClientBuilder;
import io.dapr.client.SubscriptionListener;
import io.dapr.client.domain.CloudEvent;
import io.dapr.utils.TypeRef;
import reactor.core.publisher.Mono;

/**
* Subscriber using bi-directional gRPC streaming with a dead-letter topic.
*
* <p>This example demonstrates how to forward failed messages to a dead-letter topic.
* The main listener returns {@code Status.DROP} for messages whose payload contains
* "fail", which causes the Dapr runtime to publish them to the configured
* dead-letter topic. A second subscription consumes the dead-letter topic so the
* forwarded messages are visible in the same process.
*
* <p>Usage:
* <ol>
* <li>Build and install jars: {@code mvn clean install}
* <li>cd [repo root]/examples
* <li>Run the subscriber:
* {@code dapr run --resources-path ./components/pubsub --app-id subscriber -- \
* java -jar target/dapr-java-sdk-examples-exec.jar \
* io.dapr.examples.pubsub.stream.SubscriberWithDeadLetter}
* <li>Publish messages from another terminal, e.g. containing the word "fail" to
* see them routed to the dead-letter topic.
* </ol>
*/
public class SubscriberWithDeadLetter {

private static final String DEFAULT_TOPIC_NAME = "testingtopic";
private static final String DEFAULT_DEAD_LETTER_TOPIC_NAME = "testingtopic-deadletter";
private static final String PUBSUB_NAME = "messagebus";

/**
* Main entry point for the dead-letter subscriber example.
*
* @param args Optional positional args: [topicName] [deadLetterTopicName].
* @throws Exception An Exception on startup.
*/
public static void main(String[] args) throws Exception {
String topicName = args.length >= 1 ? args[0] : DEFAULT_TOPIC_NAME;
String deadLetterTopicName = args.length >= 2 ? args[1] : DEFAULT_DEAD_LETTER_TOPIC_NAME;

try (var client = new DaprClientBuilder().buildPreviewClient()) {
System.out.println("Subscribing to dead-letter topic: " + deadLetterTopicName);

var deadLetterListener = new SubscriptionListener<String>() {
@Override
public Mono<Status> onEvent(CloudEvent<String> event) {
System.out.println("Dead-letter subscriber got: " + event.getData());
return Mono.just(Status.SUCCESS);
}

@Override
public void onError(RuntimeException exception) {
System.out.println("Dead-letter subscriber got exception: " + exception.getMessage());
}
};

System.out.println("Subscribing to topic: " + topicName
+ " (dead-letter topic: " + deadLetterTopicName + ")");

var mainListener = new SubscriptionListener<String>() {
@Override
public Mono<Status> onEvent(CloudEvent<String> event) {
String data = event.getData();
if (data != null && data.toLowerCase().contains("fail")) {
System.out.println("Subscriber dropping message to dead-letter: " + data);
return Mono.just(Status.DROP);
}
System.out.println("Subscriber got: " + data);
return Mono.just(Status.SUCCESS);
}

@Override
public void onError(RuntimeException exception) {
System.out.println("Subscriber got exception: " + exception.getMessage());
}
};

try (var deadLetterSubscription = client.subscribeToEvents(
PUBSUB_NAME, deadLetterTopicName, deadLetterListener, TypeRef.STRING);
var mainSubscription = client.subscribeToEvents(
PUBSUB_NAME, topicName, deadLetterTopicName, mainListener, TypeRef.STRING)) {
mainSubscription.awaitTermination();
}
}
}
}
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>io.dapr</groupId>
<artifactId>dapr-sdk-parent</artifactId>
<packaging>pom</packaging>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<name>dapr-sdk-parent</name>
<description>SDK for Dapr.</description>
<url>https://dapr.io</url>
Expand All @@ -18,7 +18,7 @@
<protobuf.version>3.25.5</protobuf.version>
<dapr.proto.baseurl>https://raw.githubusercontent.com/dapr/dapr/v1.18.0-rc.3/dapr/proto</dapr.proto.baseurl>
<durabletask.proto.baseurl>https://raw.githubusercontent.com/dapr/durabletask-protobuf/main/protos</durabletask.proto.baseurl>
<dapr.sdk.version>1.18.0-SNAPSHOT</dapr.sdk.version>
<dapr.sdk.version>1.18.0-rc-1</dapr.sdk.version>
<os-maven-plugin.version>1.7.1</os-maven-plugin.version>
<maven-dependency-plugin.version>3.8.1</maven-dependency-plugin.version>
<maven-antrun-plugin.version>3.1.0</maven-antrun-plugin.version>
Expand Down
2 changes: 1 addition & 1 deletion sdk-actors/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.dapr</groupId>
<artifactId>dapr-sdk-parent</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion sdk-autogen/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.dapr</groupId>
<artifactId>dapr-sdk-parent</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions sdk-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.dapr</groupId>
<artifactId>dapr-sdk-bom</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<packaging>pom</packaging>
<name>dapr-sdk-bom</name>
<description>Dapr SDK Bill of Materials (BOM) for the core SDK modules. Import this POM
Expand Down Expand Up @@ -46,7 +46,7 @@

<properties>
<gpg.skip>true</gpg.skip>
<dapr.sdk.version>1.18.0-SNAPSHOT</dapr.sdk.version>
<dapr.sdk.version>1.18.0-rc-1</dapr.sdk.version>
<!-- TODO: Remove netty-bom override once gRPC ships with Netty >= 4.1.132 (CVE-2026-33871, CVE-2026-33870) -->
<netty.version>4.1.132.Final</netty.version>
<jackson.version>2.21.2</jackson.version>
Expand Down
2 changes: 1 addition & 1 deletion sdk-springboot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.dapr</groupId>
<artifactId>dapr-sdk-parent</artifactId>
<version>1.18.0-SNAPSHOT</version>
<version>1.18.0-rc-1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Loading
Loading