Hands‑on Dapr with Java: Service Invocation and State Management Tutorial
This tutorial walks through setting up a Java‑based Dapr project, demonstrating service‑to‑service invocation and state management with Redis, including configuration, code, Kubernetes manifests, Docker packaging, and verification steps, and provides guidance on building, deploying, and testing the microservices locally.
Overview: Introduces Dapr, its purpose, history, features, and installation; the article focuses on service‑to‑service invocation and state management using Java demos.
Demo project configuration: Shows application.properties, logback.xml, the main SpringBoot application class, basic classes such as Response and DaprConfig, and the Maven pom.xml with dependencies including Dapr SDK, Spring Boot, gRPC, Protobuf, Lombok, etc., plus Dockerfile and docker‑maven‑plugin configuration for building images.
Service‑to‑service invocation: Describes two services (demo1 on port 8888, demo2 on 8880) with REST controllers, shows how demo2 calls demo1 via DaprClient, provides Kubernetes YAML for deployments and services (including Dapr annotations), and gives kubectl apply commands and curl verification steps.
State management: Explains deploying Redis in Kubernetes, creating a Dapr Redis statestore component, and demonstrates CRUD operations via curl (single/batch create, get, delete, transactional upsert/delete), notes the default last‑write‑wins mode and links to official middleware documentation.
Conclusion: Summarizes that the Java demos cover service invocation and state management, indicating that further Dapr features will be explored in later articles.
Recruitment note: Briefly mentions the hiring message from the Zero tech team at 政采云, highlighting their open‑source contributions and inviting candidates to contact them.
政采云技术
ZCY Technology Team (Zero), based in Hangzhou, is a growth-oriented team passionate about technology and craftsmanship. With around 500 members, we are building comprehensive engineering, project management, and talent development systems. We are committed to innovation and creating a cloud service ecosystem for government and enterprise procurement. We look forward to your joining us.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.