Skip to content

Commit a8eca7e

Browse files
committed
Generate updated javadocs for 1.3.0
1 parent b7aeaab commit a8eca7e

File tree

515 files changed

+2898
-1847
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

515 files changed

+2898
-1847
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ For a Maven project, add the following to your `pom.xml` file:
5151
<dependency>
5252
<groupId>io.dapr</groupId>
5353
<artifactId>dapr-sdk</artifactId>
54-
<version>1.2.0</version>
54+
<version>1.3.0</version>
5555
</dependency>
5656
<!-- Dapr's SDK for Actors (optional). -->
5757
<dependency>
5858
<groupId>io.dapr</groupId>
5959
<artifactId>dapr-sdk-actors</artifactId>
60-
<version>1.2.0</version>
60+
<version>1.3.0</version>
6161
</dependency>
6262
<!-- Dapr's SDK integration with SpringBoot (optional). -->
6363
<dependency>
6464
<groupId>io.dapr</groupId>
6565
<artifactId>dapr-sdk-springboot</artifactId>
66-
<version>1.2.0</version>
66+
<version>1.3.0</version>
6767
</dependency>
6868
...
6969
</dependencies>
@@ -77,11 +77,11 @@ For a Gradle project, add the following to your `build.gradle` file:
7777
dependencies {
7878
...
7979
// Dapr's core SDK with all features, except Actors.
80-
compile('io.dapr:dapr-sdk:1.2.0')
80+
compile('io.dapr:dapr-sdk:1.3.0')
8181
// Dapr's SDK for Actors (optional).
82-
compile('io.dapr:dapr-sdk-actors:1.2.0')
82+
compile('io.dapr:dapr-sdk-actors:1.3.0')
8383
// Dapr's SDK integration with SpringBoot (optional).
84-
compile('io.dapr:dapr-sdk-springboot:1.2.0')
84+
compile('io.dapr:dapr-sdk-springboot:1.3.0')
8585
}
8686
```
8787

daprdocs/content/en/java-sdk-docs/_index.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ For a Maven project, add the following to your `pom.xml` file:
3131
<dependency>
3232
<groupId>io.dapr</groupId>
3333
<artifactId>dapr-sdk</artifactId>
34-
<version>1.2.0</version>
34+
<version>1.3.0</version>
3535
</dependency>
3636
<!-- Dapr's SDK for Actors (optional). -->
3737
<dependency>
3838
<groupId>io.dapr</groupId>
3939
<artifactId>dapr-sdk-actors</artifactId>
40-
<version>1.2.0</version>
40+
<version>1.3.0</version>
4141
</dependency>
4242
<!-- Dapr's SDK integration with SpringBoot (optional). -->
4343
<dependency>
4444
<groupId>io.dapr</groupId>
4545
<artifactId>dapr-sdk-springboot</artifactId>
46-
<version>1.2.0</version>
46+
<version>1.3.0</version>
4747
</dependency>
4848
...
4949
</dependencies>
@@ -57,11 +57,11 @@ For a Gradle project, add the following to your `build.gradle` file:
5757
dependencies {
5858
...
5959
// Dapr's core SDK with all features, except Actors.
60-
compile('io.dapr:dapr-sdk:1.2.0')
60+
compile('io.dapr:dapr-sdk:1.3.0')
6161
// Dapr's SDK for Actors (optional).
62-
compile('io.dapr:dapr-sdk-actors:1.2.0')
62+
compile('io.dapr:dapr-sdk-actors:1.3.0')
6363
// Dapr's SDK integration with SpringBoot (optional).
64-
compile('io.dapr:dapr-sdk-springboot:1.2.0')
64+
compile('io.dapr:dapr-sdk-springboot:1.3.0')
6565
}
6666
```
6767

@@ -72,7 +72,7 @@ You can fix this by specifying a compatible OkHttp version in your project to ma
7272
<dependency>
7373
<groupId>com.squareup.okhttp3</groupId>
7474
<artifactId>okhttp</artifactId>
75-
<version>4.9.0</version>
75+
<version>1.3.0</version>
7676
</dependency>
7777
```
7878

Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
---
2+
type: docs
3+
title: "Dapr Java SDK"
4+
linkTitle: "Java"
5+
weight: 1000
6+
description: Java SDK packages for developing Dapr applications
7+
---
8+
9+
## Pre-requisites
10+
11+
- [Dapr CLI]({{< ref install-dapr-cli.md >}}) installed
12+
- Initialized [Dapr environment]({{< ref install-dapr-selfhost.md >}})
13+
- JDK 11 or above - the published jars are compatible with Java 8:
14+
- [AdoptOpenJDK 11 - LTS](https://adoptopenjdk.net/)
15+
- [Oracle's JDK 15](https://www.oracle.com/java/technologies/javase-downloads.html)
16+
- [Oracle's JDK 11 - LTS](https://www.oracle.com/java/technologies/javase-jdk11-downloads.html)
17+
- [OpenJDK](https://openjdk.java.net/)
18+
- Install one of the following build tools for Java:
19+
- [Maven 3.x](https://maven.apache.org/install.html)
20+
- [Gradle 6.x](https://gradle.org/install/)
21+
22+
## Importing Dapr's Java SDK
23+
24+
For a Maven project, add the following to your `pom.xml` file:
25+
```xml
26+
<project>
27+
...
28+
<dependencies>
29+
...
30+
<!-- Dapr's core SDK with all features, except Actors. -->
31+
<dependency>
32+
<groupId>io.dapr</groupId>
33+
<artifactId>dapr-sdk</artifactId>
34+
<version>1.3.0</version>
35+
</dependency>
36+
<!-- Dapr's SDK for Actors (optional). -->
37+
<dependency>
38+
<groupId>io.dapr</groupId>
39+
<artifactId>dapr-sdk-actors</artifactId>
40+
<version>1.3.0</version>
41+
</dependency>
42+
<!-- Dapr's SDK integration with SpringBoot (optional). -->
43+
<dependency>
44+
<groupId>io.dapr</groupId>
45+
<artifactId>dapr-sdk-springboot</artifactId>
46+
<version>1.3.0</version>
47+
</dependency>
48+
...
49+
</dependencies>
50+
...
51+
</project>
52+
```
53+
54+
For a Gradle project, add the following to your `build.gradle` file:
55+
56+
```java
57+
dependencies {
58+
...
59+
// Dapr's core SDK with all features, except Actors.
60+
compile('io.dapr:dapr-sdk:1.2.0')
61+
// Dapr's SDK for Actors (optional).
62+
compile('io.dapr:dapr-sdk-actors:1.2.0')
63+
// Dapr's SDK integration with SpringBoot (optional).
64+
compile('io.dapr:dapr-sdk-springboot:1.2.0')
65+
}
66+
```
67+
68+
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_.
69+
You can fix this by specifying a compatible OkHttp version in your project to match the version that the Dapr SDK uses:
70+
71+
```xml
72+
<dependency>
73+
<groupId>com.squareup.okhttp3</groupId>
74+
<artifactId>okhttp</artifactId>
75+
<version>1.3.0</version>
76+
</dependency>
77+
```
78+
79+
## Building blocks
80+
81+
The Java SDK allows you to interface with all of the [Dapr building blocks]({{< ref building-blocks >}}).
82+
83+
### Invoke a service
84+
85+
```java
86+
import io.dapr.client.DaprClient;
87+
import io.dapr.client.DaprClientBuilder;
88+
89+
try (DaprClient client = (new DaprClientBuilder()).build()) {
90+
// invoke a 'GET' method (HTTP) skipping serialization: \say with a Mono<byte[]> return type
91+
// for gRPC set HttpExtension.NONE parameters below
92+
response = client.invokeMethod(SERVICE_TO_INVOKE, METHOD_TO_INVOKE, "{\"name\":\"World!\"}", HttpExtension.GET, byte[].class).block();
93+
94+
// invoke a 'POST' method (HTTP) skipping serialization: to \say with a Mono<byte[]> return type
95+
response = client.invokeMethod(SERVICE_TO_INVOKE, METHOD_TO_INVOKE, "{\"id\":\"100\", \"FirstName\":\"Value\", \"LastName\":\"Value\"}", HttpExtension.POST, byte[].class).block();
96+
97+
System.out.println(new String(response));
98+
99+
// invoke a 'POST' method (HTTP) with serialization: \employees with a Mono<Employee> return type
100+
Employee newEmployee = new Employee("Nigel", "Guitarist");
101+
Employee employeeResponse = client.invokeMethod(SERVICE_TO_INVOKE, "employees", newEmployee, HttpExtension.POST, Employee.class).block();
102+
}
103+
```
104+
105+
- For a full guide on service invocation visit [How-To: Invoke a service]({{< ref howto-invoke-discover-services.md >}}).
106+
- 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
107+
108+
### Save & get application state
109+
110+
```java
111+
import io.dapr.client.DaprClient;
112+
import io.dapr.client.DaprClientBuilder;
113+
import io.dapr.client.domain.State;
114+
import reactor.core.publisher.Mono;
115+
116+
try (DaprClient client = (new DaprClientBuilder()).build()) {
117+
// Save state
118+
client.saveState(STATE_STORE_NAME, FIRST_KEY_NAME, myClass).block();
119+
120+
// Get state
121+
State<MyClass> retrievedMessage = client.getState(STATE_STORE_NAME, FIRST_KEY_NAME, MyClass.class).block();
122+
123+
// Delete state
124+
client.deleteState(STATE_STORE_NAME, FIRST_KEY_NAME).block();
125+
}
126+
```
127+
128+
- For a full list of state operations visit [How-To: Get & save state]({{< ref howto-get-save-state.md >}}).
129+
- 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
130+
131+
### Publish & subscribe to messages
132+
133+
##### Publish messages
134+
135+
```java
136+
import io.dapr.client.DaprClient;
137+
import io.dapr.client.DaprClientBuilder;
138+
import io.dapr.client.domain.Metadata;
139+
import static java.util.Collections.singletonMap;
140+
141+
try (DaprClient client = (new DaprClientBuilder()).build()) {
142+
client.publishEvent(PUBSUB_NAME, TOPIC_NAME, message, singletonMap(Metadata.TTL_IN_SECONDS, MESSAGE_TTL_IN_SECONDS)).block();
143+
}
144+
```
145+
146+
##### Subscribe to messages
147+
148+
```java
149+
import com.fasterxml.jackson.databind.ObjectMapper;
150+
import io.dapr.Topic;
151+
import io.dapr.client.domain.CloudEvent;
152+
import org.springframework.web.bind.annotation.PostMapping;
153+
import org.springframework.web.bind.annotation.RequestBody;
154+
import org.springframework.web.bind.annotation.RestController;
155+
import reactor.core.publisher.Mono;
156+
157+
@RestController
158+
public class SubscriberController {
159+
160+
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
161+
162+
@Topic(name = "testingtopic", pubsubName = "${myAppProperty:messagebus}")
163+
@PostMapping(path = "/testingtopic")
164+
public Mono<Void> handleMessage(@RequestBody(required = false) CloudEvent<?> cloudEvent) {
165+
return Mono.fromRunnable(() -> {
166+
try {
167+
System.out.println("Subscriber got: " + cloudEvent.getData());
168+
System.out.println("Subscriber got: " + OBJECT_MAPPER.writeValueAsString(cloudEvent));
169+
} catch (Exception e) {
170+
throw new RuntimeException(e);
171+
}
172+
});
173+
}
174+
175+
}
176+
```
177+
178+
- For a full list of state operations visit [How-To: Publish & subscribe]({{< ref howto-publish-subscribe.md >}}).
179+
- 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
180+
181+
### Interact with output bindings
182+
183+
```java
184+
import io.dapr.client.DaprClient;
185+
import io.dapr.client.DaprClientBuilder;
186+
187+
try (DaprClient client = (new DaprClientBuilder()).build()) {
188+
// sending a class with message; BINDING_OPERATION="create"
189+
client.invokeBinding(BINDING_NAME, BINDING_OPERATION, myClass).block();
190+
191+
// sending a plain string
192+
client.invokeBinding(BINDING_NAME, BINDING_OPERATION, message).block();
193+
}
194+
```
195+
196+
- For a full guide on output bindings visit [How-To: Use bindings]({{< ref howto-bindings.md >}}).
197+
- 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
198+
199+
### Retrieve secrets
200+
201+
```java
202+
import com.fasterxml.jackson.databind.ObjectMapper;
203+
import io.dapr.client.DaprClient;
204+
import io.dapr.client.DaprClientBuilder;
205+
import java.util.Map;
206+
207+
try (DaprClient client = (new DaprClientBuilder()).build()) {
208+
Map<String, String> secret = client.getSecret(SECRET_STORE_NAME, secretKey).block();
209+
System.out.println(JSON_SERIALIZER.writeValueAsString(secret));
210+
}
211+
```
212+
213+
- For a full guide on secrets visit [How-To: Retrieve secrets]({{< ref howto-secrets.md >}}).
214+
- 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
215+
216+
### Actors
217+
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 implementaiton, you write your Dapr actors according to the Actor model, and Dapr leverages the scalability and reliability that the underlying platform provides.
218+
219+
```java
220+
import io.dapr.actors.ActorMethod;
221+
import io.dapr.actors.ActorType;
222+
import reactor.core.publisher.Mono;
223+
224+
@ActorType(name = "DemoActor")
225+
public interface DemoActor {
226+
227+
void registerReminder();
228+
229+
@ActorMethod(name = "echo_message")
230+
String say(String something);
231+
232+
void clock(String message);
233+
234+
@ActorMethod(returns = Integer.class)
235+
Mono<Integer> incrementAndGet(int delta);
236+
}
237+
```
238+
239+
- For a full guide on actors visit [How-To: Use virtual actors in Dapr]({{< ref howto-actors.md >}}).
240+
- 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
241+
242+
## Related links
243+
- [Java SDK examples](https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples)

0 commit comments

Comments
 (0)