/dapr-skills:create-pubsub-javafrom dapr-skills
Scaffolds a Dapr pub/sub app in Java with Spring Boot, generating publisher, subscriber, or both with declarative, programmatic, or streaming subscriptions.
Ships in dapr-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This skill creates a Dapr pub/sub application in Java with Spring Boot 4 and Maven: a publisher, a subscriber or both, each its own Spring Boot app with its own copy of the message record, sharing one Redis-backed pubsub component and one dapr.yaml. The subscriber uses a declarative (default), programmatic or streaming subscription, and the apps run with dapr run -f ..
The application is built from the user's own domain. There is no built-in sample scenario: the event, its fields, its topic and what the subscriber does with it all come from the Check specification interview, and every template is filled in from the placeholder vocabulary in ../dapr-shared/pubsub-placeholders.md.
You MUST follow these phases in strict order:
## Show final message section: the closing sentence followed by the Dev Dashboard recommendation. Do NOT add any other text, summary, or commentary.The following must be installed by the user before this skill can run. Do not run the check-prereq skills; assume the prerequisites are installed.
dapr init provides Redis)Maven dependencies (written into each pom.xml during project setup, downloaded on the first build): parent org.springframework.boot:spring-boot-starter-parent 4.0.8, the BOM io.dapr.spring:dapr-spring-bom 1.19.1 imported in dependencyManagement, and io.dapr.spring:dapr-spring-boot-starter without a version, plus spring-boot-starter-webmvc and spring-boot-starter-actuator. Optional: the Diagrid Dapr Dev Dashboard.
Background on delivery guarantees, CloudEvents and the subscription types: ../dapr-shared/pubsub-concepts.md.
Placeholder vocabulary used by every template: ../dapr-shared/pubsub-placeholders.md.
Java SDK behaviour every template follows: ../dapr-shared/references/java/gotchas.md §1, §2, §3, §6 and §8.
Never build a default scenario. The application is about the user's domain, and the templates are placeholders waiting for it. Infer everything the prompt already says, then ask only what is missing, one question at a time, waiting for each answer. If the prompt gives no domain at all, ask for it — do not invent one and do not fall back to an order-processing example.
Domain, first:
<idField>: the handler deduplicates on it, so there must be exactly one per
event. Ask for the type of each field when the name does not make it obvious.Then the wiring:
@Topic in code) or streaming (the app pulls messages; no inbound port)". Inference: "streaming", "no inbound port" or "pull" → streaming; "programmatic" or @Topic → programmatic; "declarative" or "subscription YAML" → declarative.There is no hosting or style question: Java uses dapr run and Spring @RestController classes.
Feature rules:
<TopicName>-deadletter) is on unless the user declines it, and always comes with the inbound retry policy.subscription.yaml rules) and programmatic (@Rule) subscriptions. See REFERENCE.md → Routing, TTL and raw payload.Before creating any file, write out the resolved values and restate them to the user in two or three
lines, so a wrong reading is caught before it is scaffolded. Resolve them exactly as
../dapr-shared/pubsub-placeholders.md defines them (Java forms
included):
| Placeholder | Resolved from |
|---|---|
<EventName>, <EventFields>, <idField> | questions 2 and 3; <EventFields> are record components, <idField> the camelCase identifying component |
<eventVar>, <EventDescription> | <EventName>, in camelCase and as a lowercase noun phrase |
<TopicName>, <DeadLetterTopicName> | question 2; the dead-letter topic is <TopicName>-deadletter |
<TopicResource> | PascalCase of <TopicName> |
<PublishRoute>, <PublishResource>, <SubscribeRoute>, <DeadLetterRoute> | <TopicName>; the subscribe route is /events/pubsub/<TopicName> |
<ValidationCondition>, <HandlerBody> | questions 3 and 4, written in Java |
<javaPackage> | question 7: com.example. plus <ProjectRoot> lowercased with every non-alphanumeric character removed; if the result starts with a digit or is a Java reserved keyword (for example new, switch, class), prefix it with app |
Fixed, never derived from the domain: the component name pubsub, ProcessedEvents /
InMemoryProcessedEvents, TopicEventStatus, UnreadableEventAdvice, StreamingConfiguration, the
property keys dapr.pubsub.name, app.topic and app.dead-letter-topic, and the folders publisher and
subscriber. <root-kebab> is <ProjectRoot> lowercased and hyphenated (ShipTrack → shiptrack); app
ids are <root-kebab>-publisher and <root-kebab>-subscriber.
Check once whether the optional Diagrid Dapr Dev Dashboard is installed by following the Check section of ../dapr-shared/dev-dashboard.md (diagrid-dev-dashboard --version). Remember the result (DevDashboardInstalled) for the final message. This check never stops the skill: do not ask the user about it, do not install anything, and continue whether or not the dashboard is installed.
Create the project root folder inside the current location where the terminal is open, and write every file directly; there is no generator command:
mkdir <ProjectRoot>
cd <ProjectRoot>
Role both, declarative subscriber. See REFERENCE.md → Folder structures for the programmatic,
streaming and single-role trees.
<ProjectRoot>/
├── .gitignore
├── pom.xml # aggregator: modules publisher, subscriber
├── dapr.yaml
├── pubsub.http
├── README.md
├── resources/
│ ├── pubsub.yaml
│ ├── resiliency.yaml
│ └── subscription.yaml
├── publisher/
│ ├── pom.xml
│ └── src/main/
│ ├── resources/application.properties
│ └── java/<javaPackage>/publisher/
│ ├── Application.java
│ ├── <EventName>.java
│ └── <PublishResource>Controller.java
└── subscriber/
├── pom.xml
└── src/main/
├── resources/application.properties
└── java/<javaPackage>/subscriber/
├── Application.java
├── <EventName>.java
├── <EventName>Handler.java
├── ProcessedEvents.java
├── InMemoryProcessedEvents.java
├── TopicEventStatus.java
├── UnreadableEventAdvice.java
└── <TopicResource>EventsController.java
The folder under src/main/java follows the package, one folder per segment (com.example.shiptrack.publisher is com/example/shiptrack/publisher).
Copy each file from its shared file and replace every placeholder with the value resolved in Resolving
the placeholders. A file is never written with a placeholder left in it: after writing each one, check it
for a stray < ... > that is not Java generics or XML. Ports: publisher appPort 8001 / daprHTTPPort
3501, subscriber appPort 8002 / daprHTTPPort 3502.
pom.xml files (aggregator and one per app), Application.java, application.properties and .gitignore: ../dapr-shared/java-pubsub-project.md. server.port equals the app's appPort; no dapr.client.* properties; no application.yml.dapr.yaml: the Java block in REFERENCE.md → dapr.yaml, which follows the rules of ../dapr-shared/pubsub-dapr-yaml.md with command: ["mvn", "spring-boot:run"] for each app. The appID values are <root-kebab>-publisher and <root-kebab>-subscriber. Omit appPort for a streaming subscriber.resources/pubsub.yaml: ../dapr-shared/dapr-pubsub-redis.md.resources/resiliency.yaml: ../dapr-shared/dapr-pubsub-resiliency.md (dead-letter on).resources/subscription.yaml (declarative only): ../dapr-shared/dapr-pubsub-subscription.md. scopes must be exactly the subscriber appID, <root-kebab>-subscriber.<EventName> record, <PublishResource>Controller): ../dapr-shared/java-pubsub-publisher.md. Publish with daprClient.publishEvent(...).block(); never DaprMessagingTemplate.<EventName> record, TopicEventStatus, ProcessedEvents, InMemoryProcessedEvents, <EventName>Handler, and UnreadableEventAdvice for declarative and programmatic): ../dapr-shared/java-pubsub-handler.md.../dapr-shared/java-pubsub-subscriber-declarative.md;../dapr-shared/java-pubsub-subscriber-programmatic.md;../dapr-shared/java-pubsub-subscriber-streaming.md (StreamingConfiguration and <TopicResource>StreamingSubscriber, no UnreadableEventAdvice).REFERENCE.md → Routing, TTL and raw payload.pubsub.http: ../dapr-shared/pubsub-local-http.md, with camelCase JSON keys (the record component names) and ports 8001, 8002 and 3501. Subscriber only: @daprHost is the subscriber's sidecar, port 3502. Both roles (streaming included): keep @daprHost on 3501 for publishing, add @subscriberDaprHost=http://localhost:3502, and point the metadata request at {{subscriberDaprHost}}/v1.0/metadata, because the subscriptions are registered on the subscriber's sidecar only.Rules that matter:
final fields, and no field @Autowired.subscription.yaml with @Topic or subscribeToTopic for the same topic.{"status": ...} and never returns 404 (Dapr drops the message).RuntimeException inside doOnNext, and the stream has retryWhen before subscribe().IMPORTANT: After Project Setup you MUST run these checks:
mvn -q -DskipTests package in <ProjectRoot> (the aggregator builds every app). It must exit with code 0; fix any error and run it again until it does. Never report the project as created while the build fails. The first build downloads the dependencies and can take a few minutes.dapr run -f . in <ProjectRoot>.IMPORTANT: After Verify you MUST run these instructions:
Create a README.md file inside the folder. See REFERENCE.md → README key points. It contains:
dapr init provides it and it is already running in a container.dapr run -f . from the project root (the first start downloads the Maven dependencies), and how to try it with curl plus a link to pubsub.http.REFERENCE.md → README key points states them. A dropped message goes to the dead-letter topic. Streaming: the app cannot choose RETRY or DROP, and an exception in the handler must be caught so the stream stays open.GET http://localhost:3502/v1.0/metadata and the Dev Dashboard's subscriptions view.resources/pubsub.yaml is replaced while metadata.name: pubsub stays the same, so no code changes. A heading with no paragraph, or a paragraph without that link, is incomplete.../dapr-shared/dev-dashboard.md.../dapr-shared/running-with-catalyst.md (<ProjectName> is <root-kebab>).review-pubsub-publishing, review-pubsub-subscriptions and review-pubsub-components.IMPORTANT: This is the LAST step. After Create README.md, your final output MUST be ONLY the message below followed by the Dev Dashboard recommendation — no preamble, no summary, no additional commentary, only replace the with the actual value:
The pub/sub application is created. Open the README.md file in the folder for a summary and instructions for running locally.
Then add, as a separate paragraph, the block from the Final recommendation section of ../dapr-shared/dev-dashboard.md that matches DevDashboardInstalled. Use it as written. Nothing may follow it.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub diagrid-labs/dapr-skills --plugin dapr-skills33 skills in this plugin
/add-pubsub-dotnetAdds Dapr pub/sub to an existing .NET (ASP.NET Core, plain or Aspire) project. Edits only after you approve a plan. Use for "add pub/sub to my .NET project" or "subscribe this ASP.NET app to a topic". For a new project use create-pubsub-dotnet./add-pubsub-pythonAdds Dapr pub/sub to an existing Python FastAPI app. Edits only after you approve a plan. Use for "add pub/sub to my FastAPI app" or "make this Python service subscribe to a Dapr topic". For a new app use create-pubsub-python./add-workflow-dotnetAdds Dapr Workflow, activities and management endpoints to an existing .NET (ASP.NET Core, plain or Aspire) project after you approve a plan. Use for "add a workflow to my .NET project" or "make this process a durable workflow". For a new project use create-workflow-dotnet. For Diagrid use the diagrid plugin.Other plugins' skills for the same job