Environment preparation for dapr practice in Java

Wanmao Society 2022-06-24 07:56:05 阅读数:564


Dapr brief introduction

Dapr (Distributed Application Runtime) It's a portable 、 Event driven runtime , It makes it easy for any developer to build resiliency that runs on the cloud and edge 、 Stateless and stateful applications , And support the diversity of languages and developer frameworks .Dapr utilize
Sidecar Advantages of Architecture , Help us solve the challenges of building microservices , And keep the code platform independent .


As can be seen from the above architecture diagram ,Dapr It includes the following modules :

  • The service call (Service-to-service Invocation): Call through service , Services can use gRPC or HTTP Such a standard protocol to discover and reliably communicate with other services .
  • State management (State Management): Independent state management , Use key value pairs as a storage mechanism , It can be easily run for a long time 、 Highly available stateful services and stateless services run together in our services .
  • Publish subscribe (Publish and Subscribe): Publish events and subscribe to topics . The producer sends a message to a topic (Topic), But I don't know the service that receives the message ; The consumer will subscribe to the topic and receive its message , But I don't know which service produced these messages .
  • Resource binding (Resource Bindings): By establishing the binding between trigger and resource , From any external source ( Like databases , queue , File system, etc ) Receive and send events , Without message queuing , Flexible business scenarios .
  • Actors:Actor It is an independent operation unit , Have isolated operation space , In an isolated space , It has its own state and behavior , Not to be interfered with .Actor Interact with each other through messages , And at the same time , Every Actor Can only be executed by a single thread , This can effectively avoid data sharing and concurrency problems , It also ensures the scalability of the application .
  • Observability (Observability): Record indicators (metric)、 journal (log)、 link (trace) To debug and monitor Dapr And the health of the service .
  • Key management (Secrets): Support integration with public cloud and local key storage , For service retrieval .
  • Configuration Management (Configuration): By configuring API Retrieve and subscribe to the configuration items of the service in the configuration store .

install Docker

Here we use Windows 10 System as an example , install Docker.

install Hyper-V

Hyper-V It is a virtualization technology of system management program proposed by Microsoft , Can realize desktop virtualization .Hyper-V Can be used for 64 position Windows 10 pro 、 Enterprise edition and Education Edition . It can't be used in the home version .

Click on “ Small window ”, Then click “ Set up ”, Here's the picture :

 Set up

Type in the search box “ Enable or close Windows function ”, Here's the picture :

 Enable or close Windows function

Click on “ Enable or close Windows function ” after , Check “Hyper-V” All options , Here's the picture :


Click on “ determine ”, It will be installed in a moment .( You may need to restart your computer )

install Docker Desktop

visit https://desktop.docker.com/win/stable/amd64/Docker%20Desktop%20Installer.exe download , double-click Docker Desktop Installer.exe Run setup . Follow the instructions on the installation wizard to authorize the setup program and proceed with the installation .

After installation , start-up Docker Desktop, After the initialization is completed in a while , Will start the Getting Started tutorial :

Docker Desktop

This tutorial includes a simple exercise , To build an example Docker Mirror image , Run it as a container , Push and save the image to Docker Hub.

install Dapr CLI

visit https://github.com/dapr/cli/releases Download what you need Dapr CLI, If it is Linux The system can be downloaded dapr_linux_amd64.tar.gz; If it is Windows System , Can download dapr_windows_amd64.zip; If it is macOS, Can download dapr_darwin_amd64.tar.gz.

Here we use Windows System as an example .

Unzip into a directory , And add this directory to the system environment variable , Then execute the following command to verify :

dapr --version

If the following effects are displayed, the installation is successful :

dapr --version

initialization Dapr

Execute the following command :

dapr init

It will help us create the following :

  • Run a for state storage and message broker Redis Container instance
  • Run a to provide observability Zipkin Container instance
  • Create a default component folder with the above component definitions : In the user directory .dapr Folder
  • Run for local actor support Dapr Placement Service container instance

The display effect is as follows :

dapr init

Execute the following command to verify :

docker ps

If the following effects are displayed, the initialization is successful :

docker ps

here , visit http://localhost:9411/zipkin/ You can see that :


start-up Dapr Dashboard

Execute the following command :

dapr dashboard -p 9999

The display effect is as follows :

dapr dashboard -p 9999

Revisit http://localhost:9999/ You can see that :

Dapr Dashboard

Last , Thank you for being so handsome , Give it back to me. give the thumbs-up .

copyright:author[Wanmao Society],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/175/202206240409093323.html