diff --git a/daprdocs/content/en/java-sdk-docs/_index.md b/daprdocs/content/en/java-sdk-docs/_index.md
index 3982212af..5d4f4506f 100644
--- a/daprdocs/content/en/java-sdk-docs/_index.md
+++ b/daprdocs/content/en/java-sdk-docs/_index.md
@@ -11,7 +11,7 @@ cascade:
github_branch: master
---
-## Pre-requisites
+## Prerequisites
- [Dapr CLI]({{< ref install-dapr-cli.md >}}) installed
- Initialized [Dapr environment]({{< ref install-dapr-selfhost.md >}})
@@ -24,9 +24,17 @@ cascade:
- [Maven 3.x](https://maven.apache.org/install.html)
- [Gradle 6.x](https://gradle.org/install/)
-## Importing Dapr's Java SDK
+## Import Dapr's Java SDK
+
+Next, import the Java SDK packages to get started. Select your preferred build tool to learn how to import.
+
+{{< tabs Maven Gradle >}}
+
+{{% codetab %}}
+
For a Maven project, add the following to your `pom.xml` file:
+
```xml
...
@@ -55,6 +63,10 @@ For a Maven project, add the following to your `pom.xml` file:
...
```
+{{% /codetab %}}
+
+{{% codetab %}}
+
For a Gradle project, add the following to your `build.gradle` file:
@@ -70,8 +82,13 @@ dependencies {
}
```
-If you are also using Spring Boot, you may run into a common issue where the OkHttp version that the Dapr SDK uses conflicts with the one specified in the Spring Boot _Bill of Materials_.
-You can fix this by specifying a compatible OkHttp version in your project to match the version that the Dapr SDK uses:
+{{% /codetab %}}
+
+{{< /tabs >}}
+
+If you are also using Spring Boot, you may run into a common issue where the `OkHttp` version that the Dapr SDK uses conflicts with the one specified in the Spring Boot _Bill of Materials_.
+
+You can fix this by specifying a compatible `OkHttp` version in your project to match the version that the Dapr SDK uses:
```xml
@@ -81,390 +98,15 @@ You can fix this by specifying a compatible OkHttp version in your project to ma
```
-## Building blocks
+## Try it out
-The Java SDK allows you to interface with all of the [Dapr building blocks]({{< ref building-blocks >}}).
+Put the Dapr Java SDK to the test. Walk through the Java quickstarts and tutorials to see Dapr in action:
-### Invoke a service
+| SDK samples | Description |
+| ----------- | ----------- |
+| [Quickstarts]({{< ref quickstarts >}}) | Experience Dapr's API building blocks in just a few minutes using the Java SDK. |
+| [SDK samples](https://github.com/dapr/java-sdk/tree/master/examples) | Clone the SDK repo to try out some examples and get started. |
-```java
-import io.dapr.client.DaprClient;
-import io.dapr.client.DaprClientBuilder;
+## More information
-try (DaprClient client = (new DaprClientBuilder()).build()) {
- // invoke a 'GET' method (HTTP) skipping serialization: \say with a Mono return type
- // for gRPC set HttpExtension.NONE parameters below
- response = client.invokeMethod(SERVICE_TO_INVOKE, METHOD_TO_INVOKE, "{\"name\":\"World!\"}", HttpExtension.GET, byte[].class).block();
-
- // invoke a 'POST' method (HTTP) skipping serialization: to \say with a Mono return type
- response = client.invokeMethod(SERVICE_TO_INVOKE, METHOD_TO_INVOKE, "{\"id\":\"100\", \"FirstName\":\"Value\", \"LastName\":\"Value\"}", HttpExtension.POST, byte[].class).block();
-
- System.out.println(new String(response));
-
- // invoke a 'POST' method (HTTP) with serialization: \employees with a Mono return type
- Employee newEmployee = new Employee("Nigel", "Guitarist");
- Employee employeeResponse = client.invokeMethod(SERVICE_TO_INVOKE, "employees", newEmployee, HttpExtension.POST, Employee.class).block();
-}
-```
-
-- For a full guide on service invocation visit [How-To: Invoke a service]({{< ref howto-invoke-discover-services.md >}}).
-- Visit [Java SDK examples](https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples/invoke) for code samples and instructions to try out service invocation
-
-### Save & get application state
-
-```java
-import io.dapr.client.DaprClient;
-import io.dapr.client.DaprClientBuilder;
-import io.dapr.client.domain.State;
-import reactor.core.publisher.Mono;
-
-try (DaprClient client = (new DaprClientBuilder()).build()) {
- // Save state
- client.saveState(STATE_STORE_NAME, FIRST_KEY_NAME, myClass).block();
-
- // Get state
- State retrievedMessage = client.getState(STATE_STORE_NAME, FIRST_KEY_NAME, MyClass.class).block();
-
- // Delete state
- client.deleteState(STATE_STORE_NAME, FIRST_KEY_NAME).block();
-}
-```
-
-- For a full list of state operations visit [How-To: Get & save state]({{< ref howto-get-save-state.md >}}).
-- Visit [Java SDK examples](https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples/state) for code samples and instructions to try out state management
-
-### Publish & subscribe to messages
-
-##### Publish messages
-
-```java
-import io.dapr.client.DaprClient;
-import io.dapr.client.DaprClientBuilder;
-import io.dapr.client.domain.Metadata;
-import static java.util.Collections.singletonMap;
-
-try (DaprClient client = (new DaprClientBuilder()).build()) {
- client.publishEvent(PUBSUB_NAME, TOPIC_NAME, message, singletonMap(Metadata.TTL_IN_SECONDS, MESSAGE_TTL_IN_SECONDS)).block();
-}
-```
-
-##### Subscribe to messages
-
-```java
-import com.fasterxml.jackson.databind.ObjectMapper;
-import io.dapr.Topic;
-import io.dapr.client.domain.BulkSubscribeAppResponse;
-import io.dapr.client.domain.BulkSubscribeAppResponseEntry;
-import io.dapr.client.domain.BulkSubscribeAppResponseStatus;
-import io.dapr.client.domain.BulkSubscribeMessage;
-import io.dapr.client.domain.BulkSubscribeMessageEntry;
-import io.dapr.client.domain.CloudEvent;
-import io.dapr.springboot.annotations.BulkSubscribe;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RestController;
-import reactor.core.publisher.Mono;
-
-@RestController
-public class SubscriberController {
-
- private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
-
- @Topic(name = "testingtopic", pubsubName = "${myAppProperty:messagebus}")
- @PostMapping(path = "/testingtopic")
- public Mono handleMessage(@RequestBody(required = false) CloudEvent> 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);
- }
- });
- }
-
- /**
- * 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 handleMessageWithErrorHandler(@RequestBody(required = false) CloudEvent 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")
- public Mono handleMessageV2(@RequestBody(required = false) CloudEvent envelope) {
- 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);
- }
- });
- }
-
- @BulkSubscribe()
- @Topic(name = "testingtopicbulk", pubsubName = "${myAppProperty:messagebus}")
- @PostMapping(path = "/testingtopicbulk")
- public Mono handleBulkMessage(
- @RequestBody(required = false) BulkSubscribeMessage> bulkMessage) {
- return Mono.fromCallable(() -> {
- if (bulkMessage.getEntries().size() == 0) {
- return new BulkSubscribeAppResponse(new ArrayList());
- }
-
- System.out.println("Bulk Subscriber received " + bulkMessage.getEntries().size() + " messages.");
-
- List entries = new ArrayList();
- for (BulkSubscribeMessageEntry> entry : bulkMessage.getEntries()) {
- try {
- System.out.printf("Bulk Subscriber message has entry ID: %s\n", entry.getEntryId());
- CloudEvent> cloudEvent = (CloudEvent>) entry.getEvent();
- System.out.printf("Bulk Subscriber got: %s\n", cloudEvent.getData());
- entries.add(new BulkSubscribeAppResponseEntry(entry.getEntryId(), BulkSubscribeAppResponseStatus.SUCCESS));
- } catch (Exception e) {
- e.printStackTrace();
- entries.add(new BulkSubscribeAppResponseEntry(entry.getEntryId(), BulkSubscribeAppResponseStatus.RETRY));
- }
- }
- return new BulkSubscribeAppResponse(entries);
- });
- }
-}
-```
-
-##### Bulk Publish Messages
-> Note: API is in Alpha stage
-
-
-```java
-import io.dapr.client.DaprClientBuilder;
-import io.dapr.client.DaprPreviewClient;
-import io.dapr.client.domain.BulkPublishResponse;
-import io.dapr.client.domain.BulkPublishResponseFailedEntry;
-import java.util.ArrayList;
-import java.util.List;
-class Solution {
- public void publishMessages() {
- try (DaprPreviewClient client = (new DaprClientBuilder()).buildPreviewClient()) {
- // Create a list of messages to publish
- List messages = new ArrayList<>();
- for (int i = 0; i < NUM_MESSAGES; i++) {
- String message = String.format("This is message #%d", i);
- messages.add(message);
- System.out.println("Going to publish message : " + message);
- }
-
- // Publish list of messages using the bulk publish API
- BulkPublishResponse res = client.publishEvents(PUBSUB_NAME, TOPIC_NAME, "text/plain", messages).block()
- }
- }
-}
-```
-
-- For a full guide on publishing messages and subscribing to a topic [How-To: Publish & subscribe]({{< ref howto-publish-subscribe.md >}}).
-- Visit [Java SDK examples](https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples/pubsub/http) for code samples and instructions to try out pub/sub
-
-### Interact with output bindings
-
-```java
-import io.dapr.client.DaprClient;
-import io.dapr.client.DaprClientBuilder;
-
-try (DaprClient client = (new DaprClientBuilder()).build()) {
- // sending a class with message; BINDING_OPERATION="create"
- client.invokeBinding(BINDING_NAME, BINDING_OPERATION, myClass).block();
-
- // sending a plain string
- client.invokeBinding(BINDING_NAME, BINDING_OPERATION, message).block();
-}
-```
-
-- For a full guide on output bindings visit [How-To: Output bindings]({{< ref howto-bindings.md >}}).
-- Visit [Java SDK examples](https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples/bindings/http) for code samples and instructions to try out output bindings.
-
-### Interact with input bindings
-
-```java
-import org.springframework.web.bind.annotation.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@RestController
-@RequestMapping("/")
-public class myClass {
- private static final Logger log = LoggerFactory.getLogger(myClass);
- @PostMapping(path = "/checkout")
- public Mono getCheckout(@RequestBody(required = false) byte[] body) {
- return Mono.fromRunnable(() ->
- log.info("Received Message: " + new String(body)));
- }
-}
-```
-
-- For a full guide on input bindings, visit [How-To: Input bindings]({{< ref howto-triggers >}}).
-- Visit [Java SDK examples](https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples/bindings/http) for code samples and instructions to try out input bindings.
-
-### Retrieve secrets
-
-```java
-import com.fasterxml.jackson.databind.ObjectMapper;
-import io.dapr.client.DaprClient;
-import io.dapr.client.DaprClientBuilder;
-import java.util.Map;
-
-try (DaprClient client = (new DaprClientBuilder()).build()) {
- Map secret = client.getSecret(SECRET_STORE_NAME, secretKey).block();
- System.out.println(JSON_SERIALIZER.writeValueAsString(secret));
-}
-```
-
-- For a full guide on secrets visit [How-To: Retrieve secrets]({{< ref howto-secrets.md >}}).
-- Visit [Java SDK examples](https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples/secrets) for code samples and instructions to try out retrieving secrets
-
-### Actors
-An actor is an isolated, independent unit of compute and state with single-threaded execution. Dapr provides an actor implementation based on the [Virtual Actor pattern](https://www.microsoft.com/en-us/research/project/orleans-virtual-actors/), which provides a single-threaded programming model and where actors are garbage collected when not in use. With Dapr's implementation, you write your Dapr actors according to the Actor model, and Dapr leverages the scalability and reliability that the underlying platform provides.
-
-```java
-import io.dapr.actors.ActorMethod;
-import io.dapr.actors.ActorType;
-import reactor.core.publisher.Mono;
-
-@ActorType(name = "DemoActor")
-public interface DemoActor {
-
- void registerReminder();
-
- @ActorMethod(name = "echo_message")
- String say(String something);
-
- void clock(String message);
-
- @ActorMethod(returns = Integer.class)
- Mono incrementAndGet(int delta);
-}
-```
-
-- For a full guide on actors visit [How-To: Use virtual actors in Dapr]({{< ref howto-actors.md >}}).
-- Visit [Java SDK examples](https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples/actors) for code samples and instructions to try actors
-
-### Get & Subscribe to application configurations
-
-> Note this is a preview API and thus will only be accessible via the DaprPreviewClient interface and not the normal DaprClient interface
-
-```java
-import io.dapr.client.DaprClientBuilder;
-import io.dapr.client.DaprPreviewClient;
-import io.dapr.client.domain.ConfigurationItem;
-import io.dapr.client.domain.GetConfigurationRequest;
-import io.dapr.client.domain.SubscribeConfigurationRequest;
-import reactor.core.publisher.Flux;
-import reactor.core.publisher.Mono;
-
-try (DaprPreviewClient client = (new DaprClientBuilder()).buildPreviewClient()) {
- // Get configuration for a single key
- Mono item = client.getConfiguration(CONFIG_STORE_NAME, CONFIG_KEY).block();
-
- // Get configurations for multiple keys
- Mono