mirror of https://github.com/dapr/java-sdk.git
Split components dir for samples + other fixes. (#416)
This commit is contained in:
parent
17c969010f
commit
db9166ee22
|
@ -0,0 +1,13 @@
|
|||
apiVersion: dapr.io/v1alpha1
|
||||
kind: Component
|
||||
metadata:
|
||||
name: statestore
|
||||
spec:
|
||||
type: state.redis
|
||||
metadata:
|
||||
- name: redisHost
|
||||
value: localhost:6379
|
||||
- name: redisPassword
|
||||
value: ""
|
||||
- name: actorStateStore
|
||||
value: "true"
|
|
@ -15,8 +15,9 @@ import java.util.List;
|
|||
* Client for Actor runtime to invoke actor methods.
|
||||
* 1. Build and install jars:
|
||||
* mvn clean install
|
||||
* 2. Run the client:
|
||||
* dapr run --components-path ./components --app-id demoactorclient -- java -jar \
|
||||
* 2. cd to [repo-root]/examples
|
||||
* 3. Run the client:
|
||||
* dapr run --components-path ./components/actors --app-id demoactorclient -- java -jar \
|
||||
* target/dapr-java-sdk-examples-exec.jar io.dapr.examples.actors.DemoActorClient
|
||||
*/
|
||||
public class DemoActorClient {
|
||||
|
|
|
@ -18,8 +18,9 @@ import java.time.Duration;
|
|||
* Service for Actor runtime.
|
||||
* 1. Build and install jars:
|
||||
* mvn clean install
|
||||
* 2. Run the server:
|
||||
* dapr run --components-path ./components --app-id demoactorservice --app-port 3000 \
|
||||
* 2. cd to [repo-root]/examples
|
||||
* 3. Run the server:
|
||||
* dapr run --components-path ./components/actors --app-id demoactorservice --app-port 3000 \
|
||||
* -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.actors.DemoActorService -p 3000
|
||||
*/
|
||||
public class DemoActorService {
|
||||
|
|
|
@ -128,7 +128,7 @@ The `@ActorType` annotation indicates the Dapr Java SDK that this interface is a
|
|||
|
||||
Now, execute the following script in order to run DemoActorService:
|
||||
```sh
|
||||
dapr run --components-path ./components --app-id demoactorservice --app-port 3000 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.actors.DemoActorService -p 3000
|
||||
dapr run --components-path ./components/actors --app-id demoactorservice --app-port 3000 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.actors.DemoActorService -p 3000
|
||||
```
|
||||
|
||||
### Running the Actor client
|
||||
|
@ -190,21 +190,21 @@ Then, the code executes the `callActorForever` private method once per actor. In
|
|||
Use the follow command to execute the DemoActorClient:
|
||||
|
||||
```sh
|
||||
dapr run --components-path ./components --app-id demoactorclient -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.actors.DemoActorClient
|
||||
dapr run --components-path ./components/actors --app-id demoactorclient -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.actors.DemoActorClient
|
||||
```
|
||||
|
||||
Once running, the `DemoActorClient` logs will start displaying the different steps:
|
||||
First, we can see actors being activated:
|
||||

|
||||

|
||||
|
||||
Then we can see the `registerReminder` in action. `DemoActorClient` console displays the actors handling reminders:
|
||||

|
||||

|
||||
|
||||
After invoking `incrementAndGet`, the code invokes `say` method (you'll see these messages 10 times per each of the 3 actors):
|
||||

|
||||

|
||||
|
||||
On the other hand, the console for `DemoActorService` is also responding to the remote invocations:
|
||||

|
||||

|
||||
|
||||
For more details on Dapr SpringBoot integration, please refer to [Dapr Spring Boot](../../../springboot/DaprApplication.java) Application implementation.
|
||||
|
||||
|
|
|
@ -17,9 +17,8 @@ import org.apache.commons.cli.Options;
|
|||
* mvn clean install
|
||||
* 2. cd to [repo-root]/examples
|
||||
* 3. Run :
|
||||
* dapr run --components-path ./components --app-id inputbinding --app-port 3000 --dapr-http-port 3005 \
|
||||
* -- java -jar target/dapr-java-sdk-examples-exec.jar \
|
||||
* io.dapr.examples.bindings.http.InputBindingExample -p 3000
|
||||
* dapr run --components-path ./components/bindings --app-id inputbinding --app-port 3000 \
|
||||
* -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.bindings.http.InputBindingExample -p 3000
|
||||
*/
|
||||
public class InputBindingExample {
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import io.dapr.client.DaprClientBuilder;
|
|||
* mvn clean install
|
||||
* 2. cd to [repo-root]/examples
|
||||
* 3. Run the program:
|
||||
* dapr run --components-path ./components --app-id outputbinding --dapr-http-port 3006 \
|
||||
* dapr run --components-path ./components/bindings --app-id outputbinding \
|
||||
* -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.bindings.http.OutputBindingExample
|
||||
*/
|
||||
public class OutputBindingExample {
|
||||
|
|
|
@ -94,7 +94,7 @@ public class InputBindingController {
|
|||
|
||||
Execute the follow script in order to run the Input Binding example:
|
||||
```sh
|
||||
dapr run --components-path ./components --app-id inputbinding --app-port 3000 --dapr-http-port 3005 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.bindings.http.InputBindingExample -p 3000
|
||||
dapr run --components-path ./components/bindings --app-id inputbinding --app-port 3000 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.bindings.http.InputBindingExample -p 3000
|
||||
```
|
||||
|
||||
### Running the Output binding sample
|
||||
|
@ -150,7 +150,7 @@ This example binds two events: A user-defined data object (using the `myClass` o
|
|||
Use the follow command to execute the Output Binding example:
|
||||
|
||||
```sh
|
||||
dapr run --components-path ./components --app-id outputbinding --dapr-http-port 3006 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.bindings.http.OutputBindingExample
|
||||
dapr run --components-path ./components/bindings --app-id outputbinding -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.bindings.http.OutputBindingExample
|
||||
```
|
||||
|
||||
Once running, the OutputBindingExample should print the output as follows:
|
||||
|
|
|
@ -15,8 +15,7 @@ import io.dapr.exceptions.DaprException;
|
|||
* 2. Go into examples:
|
||||
* cd examples
|
||||
* 3. send a message to be saved as state:
|
||||
* dapr run --components-path ./components --dapr-http-port 3006 -- \
|
||||
* java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.exception.Client
|
||||
* dapr run -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.exception.Client
|
||||
*/
|
||||
public class Client {
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ The Dapr client is also within a try-with-resource block to properly close the c
|
|||
|
||||
Run this example with the following command:
|
||||
```sh
|
||||
dapr run --components-path ./components --dapr-http-port 3006 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.exception.Client
|
||||
dapr run -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.exception.Client
|
||||
```
|
||||
Once running, the OutputBindingExample should print the output as follows:
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ import io.dapr.client.domain.HttpExtension;
|
|||
/**
|
||||
* 1. Build and install jars:
|
||||
* mvn clean install
|
||||
* 2. cd [repo root]/examples
|
||||
* 2. Send messages to the server:
|
||||
* dapr run --components-path ./examples/components -- java -jar examples/target/dapr-java-sdk-examples-exec.jar \
|
||||
* io.dapr.examples.invoke.grpc.HelloWorldClient
|
||||
* dapr run -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.invoke.grpc.HelloWorldClient
|
||||
*/
|
||||
public class HelloWorldClient {
|
||||
|
||||
|
|
|
@ -29,11 +29,10 @@ import static io.dapr.examples.DaprExamplesProtos.SayResponse;
|
|||
/**
|
||||
* 1. Build and install jars:
|
||||
* mvn clean install
|
||||
* 2. Run in server mode:
|
||||
* dapr run --components-path ./components --app-id hellogrpc --app-port 5000 --app-protocol grpc \
|
||||
* -- java -jar examples/target/dapr-java-sdk-examples-exec.jar \
|
||||
* io.dapr.examples.invoke.grpc.HelloWorldService \
|
||||
* -p 5000
|
||||
* 2. cd [repo root]/examples
|
||||
* 3. Run in server mode:
|
||||
* dapr run --app-id hellogrpc --app-port 5000 --app-protocol grpc \
|
||||
* -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.invoke.grpc.HelloWorldService -p 5000
|
||||
*/
|
||||
public class HelloWorldService {
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ In the `GrpcHelloWorldDaprService` class, the `onInvoke` method is the most impo
|
|||
Now run the service code:
|
||||
|
||||
```sh
|
||||
dapr run --components-path ./components --app-id hellogrpc --app-port 5000 --app-protocol grpc -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.invoke.grpc.HelloWorldService -p 5000
|
||||
dapr run --app-id hellogrpc --app-port 5000 --app-protocol grpc -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.invoke.grpc.HelloWorldService -p 5000
|
||||
```
|
||||
|
||||
The `app-id` argument is used to identify this service in Dapr's runtime. The `app-port` determines which port Dapr's runtime should call into this service. The `protocol` argument informs Dapr which protocol it should use to invoke the application: `grpc` or `http`(default).
|
||||
|
@ -118,7 +118,7 @@ Finally, it will go through in an infinite loop and invoke the `say` method ever
|
|||
Finally, open a new command line terminal and run the client code to send some messages.
|
||||
|
||||
```sh
|
||||
dapr run --components-path ./components -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.invoke.grpc.HelloWorldClient
|
||||
dapr run -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.invoke.grpc.HelloWorldClient
|
||||
```
|
||||
|
||||
Once the messages are sent, use `CTRL+C` to exit Dapr.
|
||||
|
|
|
@ -14,10 +14,10 @@ import org.apache.commons.cli.Options;
|
|||
/**
|
||||
* 1. Build and install jars:
|
||||
* mvn clean install
|
||||
* 2. Run in server mode:
|
||||
* dapr run --components-path ./components --app-id invokedemo --app-port 3000 --dapr-http-port 3005 \
|
||||
* -- java -jar examples/target/dapr-java-sdk-examples-exec.jar \
|
||||
* io.dapr.examples.invoke.http.DemoService -p 3000
|
||||
* 2. cd [repo root]/examples
|
||||
* 3. Run in server mode:
|
||||
* dapr run --app-id invokedemo --app-port 3000 \
|
||||
* -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.invoke.http.DemoService -p 3000
|
||||
*/
|
||||
public class DemoService {
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@ import io.dapr.client.domain.HttpExtension;
|
|||
/**
|
||||
* 1. Build and install jars:
|
||||
* mvn clean install
|
||||
* 2. Send messages to the server:
|
||||
* dapr run --components-path ./examples/components \
|
||||
* --dapr-http-port 3006 -- java -jar examples/target/dapr-java-sdk-examples-exec.jar \
|
||||
* io.dapr.examples.invoke.http.InvokeClient 'message one' 'message two'
|
||||
* 2. cd [repo root]/examples
|
||||
* 3. Send messages to the server:
|
||||
* dapr run -- java -jar target/dapr-java-sdk-examples-exec.jar \
|
||||
* io.dapr.examples.invoke.http.InvokeClient 'message one' 'message two'
|
||||
*/
|
||||
public class InvokeClient {
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ public class DemoServiceController {
|
|||
Use the follow command to execute the demo service example:
|
||||
|
||||
```sh
|
||||
dapr run --components-path ./components --app-id invokedemo --app-port 3000 --dapr-http-port 3005 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.invoke.http.DemoService -p 3000
|
||||
dapr run --app-id invokedemo --app-port 3000 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.invoke.http.DemoService -p 3000
|
||||
```
|
||||
|
||||
Once running, the ExposerService is now ready to be invoked by Dapr.
|
||||
|
@ -131,7 +131,7 @@ The class knows the app id for the remote application. It uses the the static `D
|
|||
|
||||
Execute the follow script in order to run the InvokeClient example, passing two messages for the remote method:
|
||||
```sh
|
||||
dapr run --components-path ./components --dapr-http-port 3006 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.invoke.http.InvokeClient "message one" "message two"
|
||||
dapr run -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.invoke.http.InvokeClient "message one" "message two"
|
||||
```
|
||||
Once running, the output should display the messages sent from invoker in the demo service output as follows:
|
||||
|
||||
|
|
|
@ -15,9 +15,10 @@ import java.util.Collections;
|
|||
* Message publisher.
|
||||
* 1. Build and install jars:
|
||||
* mvn clean install
|
||||
* 2. Run the program:
|
||||
* dapr run --components-path ./components --app-id publisher --dapr-http-port 3006 -- \
|
||||
* java -jar examples/target/dapr-java-sdk-examples-exec.jar io.dapr.examples.pubsub.http.Publisher
|
||||
* 2. cd [repo root]/examples
|
||||
* 3. Run the program:
|
||||
* dapr run --components-path ./components/pubsub --app-id publisher -- \
|
||||
* java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.pubsub.http.Publisher
|
||||
*/
|
||||
public class Publisher {
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ public class SubscriberController {
|
|||
```
|
||||
Execute the follow script in order to run the Subscriber example:
|
||||
```sh
|
||||
dapr run --components-path ./components --app-id subscriber --app-port 3000 --dapr-http-port 3005 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.pubsub.http.Subscriber -p 3000
|
||||
dapr run --components-path ./components/pubsub --app-id subscriber --app-port 3000 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.pubsub.http.Subscriber -p 3000
|
||||
```
|
||||
|
||||
### Running the publisher
|
||||
|
@ -130,7 +130,7 @@ public class Publisher {
|
|||
Use the follow command to execute the Publisher example:
|
||||
|
||||
```sh
|
||||
dapr run --components-path ./components --app-id publisher --dapr-http-port 3006 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.pubsub.http.Publisher
|
||||
dapr run --components-path ./components/pubsub --app-id publisher -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.pubsub.http.Publisher
|
||||
```
|
||||
|
||||
Once running, the Publisher should print the output as follows:
|
||||
|
|
|
@ -15,9 +15,10 @@ import org.apache.commons.cli.Options;
|
|||
* Service for subscriber.
|
||||
* 1. Build and install jars:
|
||||
* mvn clean install
|
||||
* 2. Run the server:
|
||||
* dapr run --components-path ./components --app-id subscriber --app-port 3000 --dapr-http-port 3005 -- \
|
||||
* java -jar examples/target/dapr-java-sdk-examples-exec.jar io.dapr.examples.pubsub.http.Subscriber -p 3000
|
||||
* 2. cd [repo root]/examples
|
||||
* 3. Run the server:
|
||||
* dapr run --components-path ./components/pubsub --app-id subscriber --app-port 3000 -- \
|
||||
* java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.pubsub.http.Subscriber -p 3000
|
||||
*/
|
||||
public class Subscriber {
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ The Dapr client is also within a try-with-resource block to properly close the c
|
|||
|
||||
Execute the following script in order to run the example:
|
||||
```sh
|
||||
dapr run --components-path ./components -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.secrets.SecretClient movie
|
||||
dapr run --components-path ./components/secrets -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.secrets.SecretClient movie
|
||||
```
|
||||
|
||||
Once running, the program should print the output as follows:
|
||||
|
@ -165,7 +165,7 @@ The configuration defines, that the only allowed secret is `movie` and all other
|
|||
|
||||
Execute the following script in order to run this example with additional secret scoping:
|
||||
```sh
|
||||
dapr run --components-path ./components --config ./src/main/java/io/dapr/examples/secrets/config.yaml -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.secrets.SecretClient movie
|
||||
dapr run --components-path ./components/secrets --config ./src/main/java/io/dapr/examples/secrets/config.yaml -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.secrets.SecretClient movie
|
||||
```
|
||||
Once running, the program should print the output as follows:
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import java.util.Map;
|
|||
* 3. Add secret to vault:
|
||||
* vault kv put secret/dapr/movie title="[my favorite movie]"
|
||||
* 4. Read secret from example:
|
||||
* dapr run --components-path ./components -- \
|
||||
* dapr run --components-path ./components/secrets -- \
|
||||
* java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.secrets.SecretClient movie
|
||||
*/
|
||||
public class SecretClient {
|
||||
|
|
|
@ -118,7 +118,7 @@ The Dapr client is also within a try-with-resource block to properly close the c
|
|||
|
||||
Run this example with the following command:
|
||||
```sh
|
||||
dapr run --components-path ./components --dapr-http-port 3006 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.state.StateClient 'my message'
|
||||
dapr run --components-path ./components/state -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.state.StateClient 'my message'
|
||||
```
|
||||
Once running, the OutputBindingExample should print the output as follows:
|
||||
|
||||
|
|
|
@ -18,10 +18,10 @@ import java.util.List;
|
|||
/**
|
||||
* 1. Build and install jars:
|
||||
* mvn clean install
|
||||
* 2. send a message to be saved as state:
|
||||
* dapr run --components-path ./components --dapr-http-port 3006 -- \
|
||||
* java -jar examples/target/dapr-java-sdk-examples-exec.jar \
|
||||
* io.dapr.examples.state.StateClient 'my message'
|
||||
* 2. cd [repo root]/examples
|
||||
* 3. send a message to be saved as state:
|
||||
* dapr run --components-path ./components/state -- \
|
||||
* java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.state.StateClient 'my message'
|
||||
*/
|
||||
public class StateClient {
|
||||
|
||||
|
|
|
@ -21,10 +21,10 @@ import io.opentelemetry.sdk.OpenTelemetrySdk;
|
|||
/**
|
||||
* 1. Build and install jars:
|
||||
* mvn clean install
|
||||
* 2. Send messages to the server:
|
||||
* dapr run --components-path ./examples/components \
|
||||
* --port 3006 -- java -jar examples/target/dapr-java-sdk-examples-exec.jar \
|
||||
* io.dapr.examples.tracing.InvokeClient 'message one' 'message two'
|
||||
* 2. cd [repo root]/examples
|
||||
* 3. Send messages to the server:
|
||||
* dapr run -- java -jar target/dapr-java-sdk-examples-exec.jar \
|
||||
* io.dapr.examples.tracing.InvokeClient 'message one' 'message two'
|
||||
*/
|
||||
public class InvokeClient {
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ The instrumentation for the service happens via the `OpenTelemetryIterceptor` cl
|
|||
Use the follow command to execute the service:
|
||||
|
||||
```sh
|
||||
dapr run --components-path ./components --app-id tracingdemo --app-port 3000 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.tracing.TracingDemoService -p 3000
|
||||
dapr run --app-id tracingdemo --app-port 3000 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.tracing.TracingDemoService -p 3000
|
||||
```
|
||||
|
||||
Once running, the TracingDemoService is now ready to be invoked by Dapr.
|
||||
|
@ -179,7 +179,7 @@ The class knows the app id for the remote application. It uses `invokeService` m
|
|||
|
||||
Execute the follow script in order to run the InvokeClient example, passing two messages for the remote method:
|
||||
```sh
|
||||
dapr run --components-path ./components -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.tracing.InvokeClient "message one" "message two"
|
||||
dapr run -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.tracing.InvokeClient "message one" "message two"
|
||||
```
|
||||
Once running, the output should display the messages sent from invoker in the demo service output as follows:
|
||||
|
||||
|
|
|
@ -18,10 +18,10 @@ import org.apache.commons.cli.Options;
|
|||
*
|
||||
* <p>1. Build and install jars:
|
||||
* mvn clean install
|
||||
* 2. Run in server mode:
|
||||
* dapr run --components-path ./examples/components --app-id tracingdemo --app-port 3000 --port 3005 \
|
||||
* -- java -jar examples/target/dapr-java-sdk-examples-exec.jar \
|
||||
* io.dapr.examples.tracing.TracingDemoService -p 3000
|
||||
* 2. cd [repo root]/examples
|
||||
* 3. Run in server mode:
|
||||
* dapr run --app-id tracingdemo --app-port 3000 \
|
||||
* -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.tracing.TracingDemoService -p 3000
|
||||
*/
|
||||
public class TracingDemoService {
|
||||
|
||||
|
|
Loading…
Reference in New Issue