Skip to content

Commit 8abc3b3

Browse files
committed
Add quarkus and dapr after revision
1 parent cb90288 commit 8abc3b3

File tree

4 files changed

+30
-29
lines changed

4 files changed

+30
-29
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ site
44
.DS_Store
55
/blog-env
66

7-
/.quarkus
7+
/.quarkus
8+
9+
10+
.venv
File renamed without changes.

docs/posts/quarkus-dapr.md

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,51 +17,56 @@ categories:
1717

1818
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.
1919

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.
2121

2222
In this blog post, we will explore what Dapr is and how to use it in combination with the Quarkus framework.
2323

2424
<!-- more -->
2525

26+
2627
## What is Dapr?
2728

2829

29-
Dapr means Distributed Application Runtime:
30+
Dapr stands for Distributed Application Runtime:
3031
> 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.
3132
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.
3334

3435
### Dapr Building Blocks
3536

3637
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**.
3738

3839
Remember when I mentioned abstraction?
3940

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/).
4144

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/).
4346

44-
Dapr provides another building blocks:
47+
Dapr also provides other useful building blocks:
4548

46-
* **Service Invocation**: Perform direct, secure, service-to-service method calls
49+
* **Service Invocation**: Perform resilient (retries and circuit breakers), secure (mtls), service-to-service method calls.
4750
* **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
5053
* **Actors**: Encapsulate code and data in reusable actor objects as a common microservices design pattern
5154
* **Secrets management**: Securely access secrets from your application
5255
* **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.
5457
* **Cryptography**: Perform cryptographic operations without exposing keys to your application
5558
* **Jobs**: Manage the scheduling and orchestration of jobs
5659

5760
Ufa!
5861

59-
### Components
62+
How do you configure all these abstractions and integration points? Let’s look at Dapr Components.
63+
64+
### Dapr Components
6065

6166

6267
Components serve as configurations for building blocks and applications. With components, you can define specific behaviors and characteristics when utilizing a building block.
6368

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?**
6570

6671

6772
Getting Pub/Sub building block (using Kafka) as example, you can define routes to your topic:
@@ -100,18 +105,17 @@ spec:
100105
metadata:
101106
- name: connectionString
102107
value: "<CONNECTION STRING>"
103-
- name: outboxPublishPubsub # Required
108+
- name: outboxPublishPubsub # required
104109
value: "mypubsub"
105-
- name: outboxPublishTopic # Required
110+
- name: outboxPublishTopic # required
106111
value: "newOrder"
107-
- name: outboxPubsub # Optional
112+
- name: outboxPubsub # optional
108113
value: "myOutboxPubsub"
109-
- name: outboxDiscardWhenMissingState #Optional. Defaults to false
114+
- name: outboxDiscardWhenMissingState # optional, defaults to false
110115
value: false
111116
```
112117
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/).
115119
116120
117121
### What is Quarkus?
@@ -132,11 +136,10 @@ There are some benefits, I will list what makes sense for me actually:
132136

133137
If you want to see more benefits about Quarkus, [see the official documentation](https://quarkus.io/).
134138

135-
136139
## Creating you Quarkus application with Dapr
137140

138141

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).
140143

141144
```shell
142145
quarkus create app dev.matheuscruz:try-dapr -x=io.quarkiverse.dapr:quarkus-dapr
@@ -159,13 +162,12 @@ The previous command runs the Quarkus application in dev mode.
159162

160163
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!
161164

162-
163165
### Configuring the application
164166

165167
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.
166168

167169

168-
![devUI](image.png)
170+
![devUI](./assets/configuring-dapr-on-quarkus-dev-ui.png)
169171

170172
!!! tip "Looking the changes"
171173

@@ -200,7 +202,7 @@ The `daprio/daprd` container is the Dapr sidecar, configured by the Dapr DevServ
200202
"-components-path", "/components");
201203
```
202204

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/).
204206

205207

206208
## Using Pub/Sub
@@ -252,7 +254,6 @@ public class ProductResource {
252254

253255
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.
254256

255-
256257
### Consuming events
257258

258259
To make our demostration more simple, let's consume the event sent in the same application.
@@ -352,15 +353,12 @@ public class ProductCreatedHandler {
352353
353354
public record Product(String name) {}
354355
}
355-
356356
```
357357

358358
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.
359359

360360
2. Saving the product.
361361

362-
363-
364362
### Testing the state store
365363

366364

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ markdown_extensions:
5050
extra:
5151
analytics:
5252
provider: google
53-
property: G-KSLDC17QRK
53+
# property: G-KSLDC17QRK
5454
annotate:
5555
properties: [//]
5656
social:

0 commit comments

Comments
 (0)