You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/posts/quarkus-dapr.md
+25-27Lines changed: 25 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,51 +17,56 @@ categories:
17
17
18
18
If you are already using Quarkus, you are likely familiar with the incredible developer experience it offers through features such as DevServices, DevUI, and live reload. You probably appreciate how these features enhance your experience.
19
19
20
-
Now, imagine taking that developer joy to the next level by integrating it with the productivity and standardization provided by Dapr (obviously Quarkus provides standardization with Java specifications and productivity too).
20
+
Now, imagine taking that developer joy to the next level when building complex distributed cloud native applications by integrating it with the productivity and standardization provided by Dapr. While Quarkus optimizes the experience for the development process of a single application, Dapr focuses more on providing best practices and well-known patterns to help developers to build distributed applications.
21
21
22
22
In this blog post, we will explore what Dapr is and how to use it in combination with the Quarkus framework.
23
23
24
24
<!-- more -->
25
25
26
+
26
27
## What is Dapr?
27
28
28
29
29
-
Dapr means Distributed Application Runtime:
30
+
Dapr stands for Distributed Application Runtime:
30
31
> Dapr is a portable, event-driven runtime that makes it easy for any developer to build resilient, stateless, and stateful applications that run on the cloud and edge and embraces the diversity of languages and developer frameworks.
31
32
32
-
In my opinion, what makes Dapr truly remarkable is the abstraction and standardization it provides when integrated into your architecture.
33
+
In my opinion, what makes Dapr truly remarkable is the abstraction and standardization it provides in the shape of building blocks when integrated into your architecture.
33
34
34
35
### Dapr Building Blocks
35
36
36
37
So, what are Dapr building blocks? Essentially, building blocks are APIs accessed over the network through HTTP or gRPC calls. In this post, I will discuss in details only two building blocks, including: **Publish and Subscribe**, **State Management**.
37
38
38
39
Remember when I mentioned abstraction?
39
40
40
-
* Similarly, when you use the **State Management** building block, you are interacting with the Dapr runtime to store or retrieve data from a data store. This state store can be AWS DynamoDB, Azure CosmosDB, Redis, Cassandra, Firebase, and more.
41
+
<diagram-here>
42
+
43
+
* Similarly, when you use the **State Management** building block, you are interacting with the Dapr runtime to store or retrieve data from a data store. This state store can be AWS DynamoDB, Azure CosmosDB, Redis, Cassandra, Firebase, and [more](https://docs.dapr.io/reference/components-reference/supported-state-stores/).
41
44
42
-
The same principle applies to **Publish and Subscribe**. You interact with the Dapr API, and Dapr takes care of communication with the message broker on your behalf.
45
+
The same principle applies to **Publish and Subscribe**. You interact with the Dapr API, and Dapr takes care of communication with the message broker on your behalf. You can take a look at all the PubSub supported implementations here (https://docs.dapr.io/reference/components-reference/supported-pubsub/).
***Workflow**: Orchestrate logic across various microservices
48
-
***State management**: Create long running stateful services
49
-
***Bindings**: Interface with or be triggered from external systems
51
+
***State management**: Create long running stateful services by persisting and retrieving data
52
+
***Bindings**: Integrate reliably with or be triggered from external systems
50
53
***Actors**: Encapsulate code and data in reusable actor objects as a common microservices design pattern
51
54
***Secrets management**: Securely access secrets from your application
52
55
***Configuration**: Manage and be notified of application configuration changes
53
-
***Distributed lock**: Distributed locks provide mutually exclusive access to shared resources from an application.
56
+
***Distributed lock**: Distributed locks provide mutually exclusive access to shared resources from an application. No need to add new libraries to your application or new components in the infrastructure.
54
57
***Cryptography**: Perform cryptographic operations without exposing keys to your application
55
58
***Jobs**: Manage the scheduling and orchestration of jobs
56
59
57
60
Ufa!
58
61
59
-
### Components
62
+
How do you configure all these abstractions and integration points? Let’s look at Dapr Components.
63
+
64
+
### Dapr Components
60
65
61
66
62
67
Components serve as configurations for building blocks and applications. With components, you can define specific behaviors and characteristics when utilizing a building block.
63
68
64
-
If you're an experienced developer, you might be asking: **Do I need to configure retries, dead letter topics, and resilience features if I don't have the Kafka API library to set up?**
69
+
If you're an experienced developer, you might be asking: **Do I need to configure retries, dead letter queues, and resilience features if I don't have the Kafka API library to set up?**
65
70
66
71
67
72
Getting Pub/Sub building block (using Kafka) as example, you can define routes to your topic:
@@ -100,18 +105,17 @@ spec:
100
105
metadata:
101
106
- name: connectionString
102
107
value: "<CONNECTION STRING>"
103
-
- name: outboxPublishPubsub #Required
108
+
- name: outboxPublishPubsub #required
104
109
value: "mypubsub"
105
-
- name: outboxPublishTopic #Required
110
+
- name: outboxPublishTopic #required
106
111
value: "newOrder"
107
-
- name: outboxPubsub #Optional
112
+
- name: outboxPubsub #optional
108
113
value: "myOutboxPubsub"
109
-
- name: outboxDiscardWhenMissingState #Optional. Defaults to false
114
+
- name: outboxDiscardWhenMissingState # optional, defaults to false
110
115
value: false
111
116
```
112
117
113
-
There a bunch of configurations and Component types, to see a more detailed view, see the [official documentation for each building block](https://docs.dapr.io/reference/components-reference/).
114
-
118
+
There are a bunch of configurations and Component types, to see a more detailed view, see the [official documentation for each building block](https://docs.dapr.io/reference/components-reference/).
115
119
116
120
117
121
### What is Quarkus?
@@ -132,11 +136,10 @@ There are some benefits, I will list what makes sense for me actually:
132
136
133
137
If you want to see more benefits about Quarkus, [see the official documentation](https://quarkus.io/).
134
138
135
-
136
139
## Creating you Quarkus application with Dapr
137
140
138
141
139
-
Let's creat our Quarkus application with [Quarkus CLI](https://quarkus.io/guides/cli-tooling).
142
+
Let's create our Quarkus application with [Quarkus CLI](https://quarkus.io/guides/cli-tooling).
@@ -159,13 +162,12 @@ The previous command runs the Quarkus application in dev mode.
159
162
160
163
By default, the `quarkus.dapr.devservices.enabled` is set to false. This property indicates wether the DevService for Dapr extension is enabled or not. Let's enable!
161
164
162
-
163
165
### Configuring the application
164
166
165
167
Using your browser access the [DevUI Configuration](http://localhost:8080/q/dev-ui/configuration-form-editor). You will filter by `quarkus.dapr.devservice.enabled` and check the checkbox.
@@ -200,7 +202,7 @@ The `daprio/daprd` container is the Dapr sidecar, configured by the Dapr DevServ
200
202
"-components-path", "/components");
201
203
```
202
204
203
-
See the daprd refernce [here](https://docs.dapr.io/reference/arguments-annotations-overview/).
205
+
See the `daprd` reference [here](https://docs.dapr.io/reference/arguments-annotations-overview/).
204
206
205
207
206
208
## Using Pub/Sub
@@ -252,7 +254,6 @@ public class ProductResource {
252
254
253
255
By default, [Quarkus Dapr extension uses a in-memory Pub/Sub and State Store components](https://docs.quarkiverse.io/quarkus-dapr/dev/index.html#_using_in_memory_dapr_components), but you can [declare it through](https://docs.quarkiverse.io/quarkus-dapr/dev/index.html#_adding_dapr_components) `src/main/resources/components` folder.
254
256
255
-
256
257
### Consuming events
257
258
258
259
To make our demostration more simple, let's consume the event sent in the same application.
@@ -352,15 +353,12 @@ public class ProductCreatedHandler {
352
353
353
354
public record Product(String name) {}
354
355
}
355
-
356
356
```
357
357
358
358
1. Trying to get the product, the `kvstore` is the state store component name created by Quakus Dapr extension, this is a in-memory state store.
0 commit comments