mirror of https://github.com/dapr/java-sdk.git
Review changes of 0.2.0 beta (#205)
* Enable Java highlighting for state sample * Fix Why Pub-Sub link * add http ingress sample debug instructions * add invoke grpc sample debug instructions * align pubsub sample readme w code, fix vscode java arg handling * add input binding sample debug instructions * add actors sample debug instructions * change -D exec to -Dexec * add sample debugging instructions for Unix * fix some typos/language
This commit is contained in:
parent
0ed7363a3f
commit
c2d6464ff5
|
|
@ -0,0 +1,96 @@
|
||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Debug (Launch) - Current File",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "${file}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Debug (Launch)-DemoActorClient<dapr-sdk-examples>",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "io.dapr.examples.actors.http.DemoActorClient",
|
||||||
|
"projectName": "dapr-sdk-examples"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Debug (Launch)-DemoActorService<dapr-sdk-examples>",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "io.dapr.examples.actors.http.DemoActorService",
|
||||||
|
"projectName": "dapr-sdk-examples",
|
||||||
|
"args": "-port=3000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Debug (Launch)-InputBindingExample<dapr-sdk-examples>",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "io.dapr.examples.bindings.http.InputBindingExample",
|
||||||
|
"projectName": "dapr-sdk-examples",
|
||||||
|
"args": "-port=3000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Debug (Launch)-OutputBindingExample<dapr-sdk-examples>",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "io.dapr.examples.bindings.http.OutputBindingExample",
|
||||||
|
"projectName": "dapr-sdk-examples"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Debug (Launch)-HelloWorldClient<dapr-sdk-examples>",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "io.dapr.examples.invoke.grpc.HelloWorldClient",
|
||||||
|
"projectName": "dapr-sdk-examples"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Debug (Launch)-HelloWorldService<dapr-sdk-examples>",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "io.dapr.examples.invoke.grpc.HelloWorldService",
|
||||||
|
"projectName": "dapr-sdk-examples",
|
||||||
|
"args": "-port=5000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Debug (Launch)-DemoService<dapr-sdk-examples>",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "io.dapr.examples.invoke.http.DemoService",
|
||||||
|
"projectName": "dapr-sdk-examples",
|
||||||
|
"args": "-port=3000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Debug (Launch)-InvokeClient<dapr-sdk-examples>",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "io.dapr.examples.invoke.http.InvokeClient",
|
||||||
|
"projectName": "dapr-sdk-examples"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Debug (Launch)-Publisher<dapr-sdk-examples>",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "io.dapr.examples.pubsub.http.Publisher",
|
||||||
|
"projectName": "dapr-sdk-examples"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Debug (Launch)-Subscriber<dapr-sdk-examples>",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "io.dapr.examples.pubsub.http.Subscriber",
|
||||||
|
"projectName": "dapr-sdk-examples",
|
||||||
|
"args": "-port=3000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Debug (Launch)-StateClient<dapr-sdk-examples>",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "io.dapr.examples.state.StateClient",
|
||||||
|
"projectName": "dapr-sdk-examples"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -55,7 +55,7 @@ public class DemoActorService {
|
||||||
This application uses `ActorRuntime.getInstance().registerActor()` in order to register `DemoActorImpl` as an actor in the Dapr Actor runtime. Internally, it is using `DefaultObjectSerializer` for two properties: `objectSerializer` is for Dapr's sent and received objects, and `stateSerializer` is for objects to be persisted.
|
This application uses `ActorRuntime.getInstance().registerActor()` in order to register `DemoActorImpl` as an actor in the Dapr Actor runtime. Internally, it is using `DefaultObjectSerializer` for two properties: `objectSerializer` is for Dapr's sent and received objects, and `stateSerializer` is for objects to be persisted.
|
||||||
|
|
||||||
|
|
||||||
`DaprApplication.start()` method will run the Spring Boot [DaprApplication](../../../springboot/DaprApplication.java), which registers the Dapr Spring Boot controller [DaprController](../../springboot/DaprController.java). This controller contains all Actor methods implemented as endpoints. The Dapr's sidecar will call into the controller.
|
`DaprApplication.start()` method will run the Spring Boot [DaprApplication](../../../springboot/DaprApplication.java), which registers the Dapr Spring Boot controller [DaprController](../../../springboot/DaprController.java). This controller contains all Actor methods implemented as endpoints. The Dapr's sidecar will call into the controller.
|
||||||
|
|
||||||
See [DemoActorImpl](DemoActorImpl.java) for details on the implementation of an actor:
|
See [DemoActorImpl](DemoActorImpl.java) for details on the implementation of an actor:
|
||||||
```java
|
```java
|
||||||
|
|
@ -108,6 +108,36 @@ cd to [repo-root]
|
||||||
dapr run --app-id demoactorservice --app-port 3000 --port 3005 -- mvn exec:java -pl=examples -Dexec.mainClass=io.dapr.examples.actors.http.DemoActorService -Dexec.args="-p 3000"
|
dapr run --app-id demoactorservice --app-port 3000 --port 3005 -- mvn exec:java -pl=examples -Dexec.mainClass=io.dapr.examples.actors.http.DemoActorService -Dexec.args="-p 3000"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Debugging the Demo actor service
|
||||||
|
|
||||||
|
If you want to debug the actor service, you have to make sure to provide the port as an argument.
|
||||||
|
|
||||||
|
For VSCode you can find a sample launch.json which includes:
|
||||||
|
```json
|
||||||
|
...
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Debug (Launch)-DemoActorService<dapr-sdk-examples>",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "io.dapr.examples.actors.http.DemoActorService",
|
||||||
|
"projectName": "dapr-sdk-examples",
|
||||||
|
"args": "-port=3000"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
Use the following commands to run the Dapr sidecar.
|
||||||
|
|
||||||
|
For Linux and MacOS:
|
||||||
|
```sh
|
||||||
|
dapr run --app-id demoactorservice --app-port 3000 --port 3005 --grpc-port 5001 -- cat
|
||||||
|
```
|
||||||
|
|
||||||
|
For Windows:
|
||||||
|
```sh
|
||||||
|
dapr run --app-id demoactorservice --app-port 3000 --port 3005 --grpc-port 5001 -- waitfor FOREVER
|
||||||
|
```
|
||||||
|
|
||||||
### Running the Actor client
|
### Running the Actor client
|
||||||
|
|
||||||
The actor client is a simple java class with a main method that uses the Dapr Actor capabilities in order to create the actors and execute the different methods based on the Actor pattern.
|
The actor client is a simple java class with a main method that uses the Dapr Actor capabilities in order to create the actors and execute the different methods based on the Actor pattern.
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,36 @@ cd to [repo-root]/examples
|
||||||
dapr run --app-id inputbinding --app-port 3000 --port 3005 -- mvn exec:java -Dexec.mainClass=io.dapr.examples.bindings.http.InputBindingExample -Dexec.args="-p 3000"
|
dapr run --app-id inputbinding --app-port 3000 --port 3005 -- mvn exec:java -Dexec.mainClass=io.dapr.examples.bindings.http.InputBindingExample -Dexec.args="-p 3000"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Debugging the Input binding sample
|
||||||
|
|
||||||
|
If you want to debug the `InputBindingExample`, you have to make sure to provide the port as an argument.
|
||||||
|
|
||||||
|
For VSCode you can find a sample launch.json which includes:
|
||||||
|
```json
|
||||||
|
...
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Debug (Launch)-InputBindingExample<dapr-sdk-examples>",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "io.dapr.examples.bindings.http.InputBindingExample",
|
||||||
|
"projectName": "dapr-sdk-examples",
|
||||||
|
"args": "-port=3000"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
Use the following commands to run the Dapr sidecar.
|
||||||
|
|
||||||
|
For Linux and MacOS:
|
||||||
|
```sh
|
||||||
|
dapr run --app-id inputbinding --app-port 3000 --port 3005 --grpc-port 5001 -- cat
|
||||||
|
```
|
||||||
|
|
||||||
|
For Windows:
|
||||||
|
```sh
|
||||||
|
dapr run --app-id inputbinding --app-port 3000 --port 3005 --grpc-port 5001 -- waitfor FOREVER
|
||||||
|
```
|
||||||
|
|
||||||
### Running the Output binding sample
|
### Running the Output binding sample
|
||||||
|
|
||||||
The output binding application is a simple java class with a main method that uses the Dapr Client to invoke binding.
|
The output binding application is a simple java class with a main method that uses the Dapr Client to invoke binding.
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ mvn install
|
||||||
|
|
||||||
### Running the example's service
|
### Running the example's service
|
||||||
|
|
||||||
The first component is the service. It has a simple API with the `Say` method. This method will print out each message received from the client. The proto file below contains the description of the HelloWorld service found in the `./proto/examples/helloworld.proto` file:
|
The first component is the service. It has a simple API with the `say` method. This method will print out each message received from the client. The proto file below contains the description of the HelloWorld service found in the `./examples/proto/helloworld.proto` file:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
service HelloWorld {
|
service HelloWorld {
|
||||||
|
|
@ -50,14 +50,11 @@ private static class GrpcHelloWorldDaprService extends DaprClientGrpc.DaprClient
|
||||||
public void onInvoke(DaprClientProtos.InvokeEnvelope request, StreamObserver<Any> responseObserver) {
|
public void onInvoke(DaprClientProtos.InvokeEnvelope request, StreamObserver<Any> responseObserver) {
|
||||||
try {
|
try {
|
||||||
if ("say".equals(request.getMethod())) {
|
if ("say".equals(request.getMethod())) {
|
||||||
// IMPORTANT: do not use Any.unpack(), use Type.ParseFrom() instead.
|
SayRequest sayRequest =
|
||||||
SayRequest sayRequest = SayRequest.parseFrom(request.getData().getValue());
|
SayRequest.newBuilder().setMessage(request.getData().getValue().toStringUtf8()).build();
|
||||||
SayResponse sayResponse = this.say(sayRequest);
|
SayResponse sayResponse = this.say(sayRequest);
|
||||||
responseObserver.onNext(Any.pack(sayResponse));
|
responseObserver.onNext(Any.pack(sayResponse));
|
||||||
}
|
}
|
||||||
} catch (InvalidProtocolBufferException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
responseObserver.onError(e);
|
|
||||||
} finally {
|
} finally {
|
||||||
responseObserver.onCompleted();
|
responseObserver.onCompleted();
|
||||||
}
|
}
|
||||||
|
|
@ -75,6 +72,36 @@ dapr run --app-id hellogrpc --app-port 5000 --protocol grpc -- mvn exec:java -pl
|
||||||
|
|
||||||
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).
|
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).
|
||||||
|
|
||||||
|
### Debugging the example's service
|
||||||
|
|
||||||
|
If you want to debug the `HelloWorldService`, you have to make sure to provide the port as an argument.
|
||||||
|
|
||||||
|
For VSCode you can find a sample launch.json which includes:
|
||||||
|
```json
|
||||||
|
...
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Debug (Launch)-HelloWorldService<dapr-sdk-examples>",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "io.dapr.examples.invoke.grpc.HelloWorldService",
|
||||||
|
"projectName": "dapr-sdk-examples",
|
||||||
|
"args": "-port=5000"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
Use the following commands to run the Dapr sidecar.
|
||||||
|
|
||||||
|
For Linux and MacOS:
|
||||||
|
```sh
|
||||||
|
dapr run --app-id hellogrpc --app-port 5000 --protocol grpc --port 3005 --grpc-port 5001 -- cat
|
||||||
|
```
|
||||||
|
|
||||||
|
For Windows:
|
||||||
|
```sh
|
||||||
|
dapr run --app-id hellogrpc --app-port 5000 --protocol grpc --port 3005 --grpc-port 5001 -- waitfor FOREVER
|
||||||
|
```
|
||||||
|
|
||||||
### Running the example's client
|
### Running the example's client
|
||||||
|
|
||||||
The other component is the client. It will send one message per second to the service via Dapr's invoke API using Dapr's SDK. Open the `HelloWorldClient.java` file, it uses the Dapr's Java SDK to invoke the `say` method on the service above:
|
The other component is the client. It will send one message per second to the service via Dapr's invoke API using Dapr's SDK. Open the `HelloWorldClient.java` file, it uses the Dapr's Java SDK to invoke the `say` method on the service above:
|
||||||
|
|
@ -103,7 +130,7 @@ private static class HelloWorldClient {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
First, it creates an instance of `DaprClient` via `DaprClientBuilder`. The protocol used by DaprClient is transparent to the application. The HTTP and GRPC ports used by Dapr's sidecar are automatically chosen and exported as environment variables: `DAPR_HTTP_PORT` and `DAPR_GRPC_PORT`. Dapr's Java SDK references these environment variables when communicating to Dapr's sidecar.
|
First, it creates an instance of `DaprClient` via `DaprClientBuilder`. The protocol used by DaprClient can be set with the JVM's system property `dapr.grpc.enabled` or environment variable `DAPR_GRPC_ENABLED`. If both are not set, the default is to use HTTP. The HTTP and GRPC ports used by Dapr's sidecar are automatically chosen and exported as environment variables to the app: `DAPR_HTTP_PORT` and `DAPR_GRPC_PORT`. Dapr's Java SDK references these environment variables when communicating to Dapr's sidecar.
|
||||||
|
|
||||||
Finally, it will go through in an infinite loop and invoke the `say` method every second. Notice the use of `block()` on the return from `invokeService` - it is required to actually make the service invocation via a [Mono](https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html) object.
|
Finally, it will go through in an infinite loop and invoke the `say` method every second. Notice the use of `block()` on the return from `invokeService` - it is required to actually make the service invocation via a [Mono](https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html) object.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ mvn install
|
||||||
|
|
||||||
The Demo service application is meant to expose a method that can be remotely invoked. In this example, the service code has two parts:
|
The Demo service application is meant to expose a method that can be remotely invoked. In this example, the service code has two parts:
|
||||||
|
|
||||||
In the `DemoService.java` file, you will find the `DemoService` class, containing the main method. The main method uses the Spring Boot´s DaprApplication class for initializing the `ExposerServiceController`. See the code snippet below:
|
In the `DemoService.java` file, you will find the `DemoService` class, containing the main method. The main method uses the Spring Boot´s DaprApplication class for initializing the `DemoServiceController`. See the code snippet below:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
public class DemoService {
|
public class DemoService {
|
||||||
|
|
@ -92,8 +92,37 @@ Use the follow command to execute the demo service example:
|
||||||
dapr run --app-id invokedemo --app-port 3000 --port 3005 -- mvn exec:java -pl=examples -Dexec.mainClass=io.dapr.examples.invoke.http.DemoService -Dexec.args="-p 3000"
|
dapr run --app-id invokedemo --app-port 3000 --port 3005 -- mvn exec:java -pl=examples -Dexec.mainClass=io.dapr.examples.invoke.http.DemoService -Dexec.args="-p 3000"
|
||||||
```
|
```
|
||||||
|
|
||||||
Once running, the ExposerService is now ready to be invoked by Dapr.
|
Once running, the DemoService is now ready to be invoked by Dapr.
|
||||||
|
|
||||||
|
### Debugging the Demo service sample
|
||||||
|
|
||||||
|
If you want to debug the `DemoService`, you have to make sure to provide the port as an argument.
|
||||||
|
|
||||||
|
For VSCode you can find a sample launch.json which includes:
|
||||||
|
```json
|
||||||
|
...
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Debug (Launch)-DemoService<dapr-sdk-examples>",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "io.dapr.examples.invoke.http.DemoService",
|
||||||
|
"projectName": "dapr-sdk-examples",
|
||||||
|
"args": "-port=3000"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
Use the following commands to run the Dapr sidecar.
|
||||||
|
|
||||||
|
For Linux and MacOS:
|
||||||
|
```sh
|
||||||
|
dapr run --app-id invokedemo --app-port 3000 --port 3005 --grpc-port 5001 -- cat
|
||||||
|
```
|
||||||
|
|
||||||
|
For Windows:
|
||||||
|
```sh
|
||||||
|
dapr run --app-id invokedemo --app-port 3000 --port 3005 --grpc-port 5001 -- waitfor FOREVER
|
||||||
|
```
|
||||||
|
|
||||||
### Running the InvokeClient sample
|
### Running the InvokeClient sample
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Dapr Pub-Sub Sample
|
# Dapr Pub-Sub Sample
|
||||||
|
|
||||||
In this sample, we'll create a publisher and a subscriber java applications using Dapr, based on the publish-subcribe pattern. The publisher will generate messages of a specific topic, while subscriber will listen for messages of specific topic. See [Why Pub-Sub](#why-pub-sub) to understand when this pattern might be a good choice for your software architecture.
|
In this sample, we'll create a publisher and a subscriber java applications using Dapr, based on the publish-subcribe pattern. The publisher will generate messages of a specific topic, while subscriber will listen for messages of specific topic. See [Why Pub-Sub](https://github.com/dapr/samples/tree/master/4.pub-sub#why-pub-sub) to understand when this pattern might be a good choice for your software architecture.
|
||||||
|
|
||||||
Visit [this](https://github.com/dapr/docs/tree/master/concepts/publish-subscribe-messaging) link for more information about Dapr and Pub-Sub.
|
Visit [this](https://github.com/dapr/docs/tree/master/concepts/publish-subscribe-messaging) link for more information about Dapr and Pub-Sub.
|
||||||
|
|
||||||
|
|
@ -52,16 +52,16 @@ public class SubscriberController {
|
||||||
///...
|
///...
|
||||||
@GetMapping("/dapr/subscribe")
|
@GetMapping("/dapr/subscribe")
|
||||||
public byte[] daprConfig() throws Exception {
|
public byte[] daprConfig() throws Exception {
|
||||||
return SERIALIZER.serialize(new String[] { "message" });
|
return SERIALIZER.serialize(new String[] { "testingtopic" });
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(path = "/message")
|
@PostMapping(path = "/testingtopic")
|
||||||
public Mono<Void> handleMessage(@RequestBody(required = false) byte[] body,
|
public Mono<Void> handleMessage(@RequestBody(required = false) byte[] body,
|
||||||
@RequestHeader Map<String, String> headers) {
|
@RequestHeader Map<String, String> headers) {
|
||||||
return Mono.fromRunnable(() -> {
|
return Mono.fromRunnable(() -> {
|
||||||
try {
|
try {
|
||||||
// Dapr's event is compliant to CloudEvent.
|
// Dapr's event is compliant to CloudEvent.
|
||||||
CloudEventEnvelope envelope = SERIALIZER.deserialize(body, CloudEventEnvelope.class);
|
CloudEvent envelope = CloudEvent.deserialize(body);
|
||||||
|
|
||||||
String message = envelope.getData() == null ? "" : new String(envelope.getData());
|
String message = envelope.getData() == null ? "" : new String(envelope.getData());
|
||||||
System.out.println("Subscriber got message: " + message);
|
System.out.println("Subscriber got message: " + message);
|
||||||
|
|
@ -77,6 +77,36 @@ Execute the follow script in order to run the Subscriber example:
|
||||||
dapr run --app-id subscriber --app-port 3000 --port 3005 -- mvn exec:java -pl=examples -Dexec.mainClass=io.dapr.examples.pubsub.http.Subscriber -Dexec.args="-p 3000"
|
dapr run --app-id subscriber --app-port 3000 --port 3005 -- mvn exec:java -pl=examples -Dexec.mainClass=io.dapr.examples.pubsub.http.Subscriber -Dexec.args="-p 3000"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Debugging the subscriber
|
||||||
|
|
||||||
|
If you want to debug the `Subscriber`, you have to make sure to provide the port as an argument.
|
||||||
|
|
||||||
|
For VSCode you can find a sample launch.json which includes:
|
||||||
|
```json
|
||||||
|
...
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"name": "Debug (Launch)-Subscriber<dapr-sdk-examples>",
|
||||||
|
"request": "launch",
|
||||||
|
"mainClass": "io.dapr.examples.pubsub.http.Subscriber",
|
||||||
|
"projectName": "dapr-sdk-examples",
|
||||||
|
"args": "-port=3000"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
Use the following commands to run the Dapr sidecar.
|
||||||
|
|
||||||
|
For Linux and MacOS
|
||||||
|
```sh
|
||||||
|
dapr run --app-id subscriber --app-port 3000 --port 3005 --grpc-port 5001 -- cat
|
||||||
|
```
|
||||||
|
|
||||||
|
For Windows:
|
||||||
|
```sh
|
||||||
|
dapr run --app-id subscriber --app-port 3000 --port 3005 --grpc-port 5001 -- waitfor FOREVER
|
||||||
|
```
|
||||||
|
|
||||||
### Running the publisher
|
### Running the publisher
|
||||||
|
|
||||||
The other component is the publisher. It is a simple java application with a main method that uses the Dapr HTTP Client to publish 10 messages to an specific topic.
|
The other component is the publisher. It is a simple java application with a main method that uses the Dapr HTTP Client to publish 10 messages to an specific topic.
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ mvn install
|
||||||
### Running the StateClient
|
### Running the StateClient
|
||||||
This example uses the Java SDK Dapr client in order to save, retrieve and delete a state, in this case, an instance of a class. See the code snippet bellow:
|
This example uses the Java SDK Dapr client in order to save, retrieve and delete a state, in this case, an instance of a class. See the code snippet bellow:
|
||||||
|
|
||||||
```
|
```java
|
||||||
public class StateClient {
|
public class StateClient {
|
||||||
///...
|
///...
|
||||||
private static final String KEY_NAME = "mykey";
|
private static final String KEY_NAME = "mykey";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue