Skip to content

Commit

Permalink
feat: Add dead letter topic example to the docs.
Browse files Browse the repository at this point in the history
Signed-off-by: Charlie Mk <carlosrb00@gmail.com>
  • Loading branch information
charlieMk1 committed Apr 24, 2023
1 parent c097ea6 commit eb6a149
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion daprdocs/content/en/java-sdk-docs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,26 @@ public class SubscriberController {
});
}

/**
* Handles a registered publish endpoint on this app adding a topic which manage to forward undeliverable messages.
*
* @param cloudEvent The cloud event received.
* @return A message containing the time.
*/
@Topic(name = "testingtopic", pubsubName = "${myAppProperty:messagebus}",
deadLetterTopic = "${deadLetterProperty:deadTopic}")
@PostMapping(path = "/testingtopic")
public Mono<Void> handleMessageWithErrorHandler(@RequestBody(required = false) CloudEvent<String> cloudEvent) {
return Mono.fromRunnable(() -> {
try {
System.out.println("Subscriber got: " + cloudEvent.getData());
System.out.println("Subscriber got: " + OBJECT_MAPPER.writeValueAsString(cloudEvent));
} catch (Exception e) {
throw new RuntimeException(e);
}
});
}

@Topic(name = "testingtopic", pubsubName = "${myAppProperty:messagebus}",
rule = @Rule(match = "event.type == 'myevent.v2'", priority = 1))
@PostMapping(path = "/testingtopicV2")
Expand All @@ -191,7 +211,7 @@ public class SubscriberController {
}
});
}

@BulkSubscribe()
@Topic(name = "testingtopicbulk", pubsubName = "${myAppProperty:messagebus}")
@PostMapping(path = "/testingtopicbulk")
Expand Down

0 comments on commit eb6a149

Please sign in to comment.