quarkus-reactive-messaging-nats-jetstream
CLAUDE.md17 starsChanged 9 days agoApache-2.0View on GitHub
This is a Quarkus extension that integrates NATS JetStream with SmallRye Reactive Messaging, allowing Quarkus applications to use NATS JetStream for message streaming in both JVM and Native modes. The connector name is quarkus-jetstream. This is a multi-module Maven project containing two Quarkus extensions: JetStreamConnector (messaging/runtime/src/main/java/.../JetStreamConnector.java): - Main entry point implementing both InboundConnector and OutboundConnector - Creates publishers for incoming channels and subscribers for outgoing channels - Manages health reporting for all message processors - Uses factory pattern to create…
In this repository39 other files it gives its agents.
- ask-mattSkill
- chief-of-staffSkill
- claude-handoffSkill
- codebase-designSkill
- code-reviewSkill
- diagnosing-bugsSkill
- domain-modelingSkill
- git-guardrails-claude-codeSkill
- grillingSkill
- grill-meSkill
- grill-with-docsSkill
- handoffSkill
- implementSkill
- implement-specSkill
- improve-codebase-architectureSkill
- loop-meSkill
- migrate-to-shoehornSkill
- prototypeSkill
- prSkill
- researchSkill
- retroSkill
- scaffold-exercisesSkill
- setup-matt-pocock-skillsSkill
- setup-pre-commitSkill
- setup-ts-deep-modulesSkill
- software-factorySkill
- tddSkill
- teachSkill
- to-questionnaireSkill
- to-specSkill
- to-ticketsSkill
- triageSkill
- wait-whatSkill
- wayfinderSkill
- wizardSkill
- writing-beatsSkill
- writing-for-agentsSkill
- writing-fragmentsSkill
- writing-shapeSkill
The file
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
This is a Quarkus extension that integrates NATS JetStream with SmallRye Reactive Messaging, allowing Quarkus applications to use NATS JetStream for message streaming in both JVM and Native modes. The connector name is quarkus-jetstream.
Build Commands
Full Build
./mvnw clean installBuild without formatting
./mvnw clean install -Dno-formatNative Build
./mvnw install -Dnative -Dquarkus.native.container-build -Dnative.surefire.skipRun Tests Only
./mvnw testRun Integration Tests
./mvnw verify -PitRun Single Test
# For client extension tests
./mvnw test -pl client/runtime -Dtest=ClassName
./mvnw test -pl client/deployment -Dtest=ClassName
# For messaging extension tests
./mvnw test -pl messaging/deployment -Dtest=ClassName
# For integration tests
./mvnw test -pl client/integration-tests -Dtest=ClassName
./mvnw test -pl messaging/integration-tests -Dtest=ClassNameBuild Documentation
./mvnw install -PdocsModule Structure
This is a multi-module Maven project containing two Quarkus extensions:
- client/: The NATS client extension (
quarkus-nats-jetstream-client)- client/runtime/: Reactive NATS/JetStream client, datasource configuration (
quarkus.messaging.nats.*),ClientCDI beans, TLS, tracing and resource (stream/consumer/KV/object store) initialization - client/deployment/: Build steps registering the
Clientbeans, serializer, tracing, native image support and Dev Services - client/integration-tests/: End-to-end tests of the client extension on its own (JVM and Native)
- client/runtime/: Reactive NATS/JetStream client, datasource configuration (
- messaging/: The SmallRye Reactive Messaging connector extension (
quarkus-messaging-nats-jetstream), built on the client extension- messaging/runtime/: The
quarkus-jetstreamconnector, message processors, channel configuration and request/reply - messaging/deployment/: Build steps registering the connector and per-channel processor beans
- messaging/integration-tests/: End-to-end tests using the extension
- messaging/runtime/: The
- docs/: Documentation in AsciiDoc format
Architecture
Core Components
JetStreamConnector (messaging/runtime/src/main/java/.../JetStreamConnector.java):
- Main entry point implementing both
InboundConnectorandOutboundConnector - Creates publishers for incoming channels and subscribers for outgoing channels
- Manages health reporting for all message processors
- Uses factory pattern to create processor instances
Message Processors:
- MessagePublisherProcessor: Handles incoming messages from NATS JetStream (pull or push consumers)
- MessageSubscriberProcessor: Handles outgoing messages to NATS JetStream
- Located in
messaging/runtime/src/main/java/.../processors/ - Each processor tracks its own health status
Client Layer (client/runtime/src/main/java/.../client/):
- connection/: Manages NATS connections and configuration
- context/: Handles JetStream context creation and management
- consumer/: Consumer implementations (pull and push)
- publisher/: Message publishing logic
- stream/: Stream management and configuration
- store/: Key/Value store support
- tracing/: OpenTelemetry integration for distributed tracing
Configuration (client/runtime/src/main/java/.../client/runtime/configuration/ for datasources, messaging/runtime/src/main/java/.../connector/configuration/ for channels):
- mapper/: Maps between Quarkus configuration and NATS JetStream API objects
- Handles both stream and consumer configuration (pull and push)
- Supports Key/Value store configuration
Message Flow
Incoming (Pull/Push Consumer → Application):
JetStreamConnector.getPublisher()called by SmallRye Reactive Messaging- Factory creates appropriate
MessagePublisherProcessor - Processor subscribes to NATS JetStream consumer
- Messages flow to application via Reactive Streams
Publisher
Outgoing (Application → JetStream Stream):
JetStreamConnector.getSubscriber()called by SmallRye Reactive Messaging- Factory creates
MessageSubscriberProcessor - Application publishes messages via Reactive Streams
Subscriber - Processor publishes to specified NATS JetStream subject/stream
Configuration Hierarchy
- Connection-level:
quarkus.messaging.nats.connection.*- Defines NATS server connection - Stream-level:
quarkus.messaging.nats.streams.[stream-name].*- Defines JetStream streams - Consumer-level:
quarkus.messaging.nats.streams.[stream-name].pull-consumers.[consumer-name].*orpush-consumers.[consumer-name].* - Channel-level:
mp.messaging.incoming.[channel].*ormp.messaging.outgoing.[channel].*- Maps channels to streams/consumers/subjects
Key Development Notes
Testing Strategy
- client/runtime/src/test/: Unit tests of the client (tracing, configuration mapping)
- client/deployment/src/test/: Client tests against a NATS Testcontainer (
ClientTest), and tests that start a Quarkus application with only the client extension (no Reactive Messaging). The NATS container used by Dev Services and these tests isJetStreamContainerinclient/deployment - messaging/deployment/src/test/: Unit tests that start a Quarkus application with the extension
- client/integration-tests/src/test/: Integration tests of the client extension without Reactive Messaging (JVM and Native)
- messaging/integration-tests/src/test/: Integration tests using the full extension (JVM and Native)
- Tests use Quarkus Dev Services to automatically start a NATS container via Testcontainers
- Common test utilities in
messaging/deployment/src/test/java/.../test/
Dev Services
The extension provides Dev Services support that automatically starts a NATS server container during development and testing. Configuration in client/deployment/src/main/java/.../client/deployment/JetStreamDevServicesProcessor.java.
Client Thread Pool
Each Client owns a thread pool (ClientThreadPool), configured per datasource with quarkus.messaging.nats.thread-pool.* (ThreadPoolConfiguration) and shut down in Client.close(). All blocking client calls (publish, next/fetch, stream/consumer/KV/object store operations) run on it via Context.threadPool(). It is a jboss-threads EnhancedQueueExecutor, or a virtual thread per task when thread-pool.virtual-threads=true. Exceptions: the NATS connection's internal executor (Options.executor) uses the injected Quarkus ExecutorService, and subscribe(...) loops use dedicated single-thread executors.
GraalVM Native Support
Native image configuration for the NATS Java client (reflection, runtime-initialized classes, SSL) is handled by NatsClientProcessor in client/deployment/.
Annotation Processors
The build uses several annotation processors:
- SmallRye Connector Attribute Processor: Generates connector configuration metadata
- Lombok: For code generation
- Quarkus Extension Processor: Generates extension metadata
Channel Configuration Requirements
Incoming channels require:
stream: The JetStream stream nameconsumer: The consumer name (must be pre-configured or auto-configured)
Outgoing channels require:
stream: The JetStream stream namesubject: The subject to publish to
Health Checks
The connector implements HealthReporter and reports both liveness and readiness based on the health status of all active message processors (connection state, consumer state, etc.).
Technology Stack
- Quarkus: 4.0.0.Beta1
- Java: 21 (minimum,
maven.compiler.release) - NATS Java Client: 2.27.0
- SmallRye Reactive Messaging: Provided by Quarkus BOM
- OpenTelemetry: For distributed tracing
- Lombok: For reducing boilerplate
- Jackson: For JSON serialization/deserialization
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

