| name | simplemq-maintainer |
| description | Use when: modifying, extending, refactoring, reviewing, or debugging the SimpleMq library in this monorepo (consumer registration, MQ bootstrap, message dispatching, channels, connection lifecycle, publisher behavior, and broker config validation). |
SimpleMq Maintainer
Goal
Apply safe, low-regression changes in the SimpleMq library with focus on:
- Runtime reliability
- Resource lifecycle and disposal
- Performance in hot paths
- Clear separation of responsibilities
Project-Specific Architecture
Core flow (current baseline):
- AddSimpleMQ extension configures options, registers services, and registers consumer metadata.
- ConsumerRegistrationBuilder scans consumer types and builds compiled invokers.
- MQBootstrapService sets up broker topology, creates one channel per queue, and subscribes consumers.
- ConsumerMessageDispatcher handles per-message routing-key checks, payload parsing, scope creation, invocation, and ack or nack.
- ConnectionService owns RabbitMQ connection and channel creation lifecycle.
Relevant files:
- libs/SimpleMQ/Extensions/AddSimpleMQ.cs
- libs/SimpleMQ/Services/ConsumerRegistrationBuilder.cs
- libs/SimpleMQ/Services/ConsumerRegistration.cs
- libs/SimpleMQ/Services/MQBootstrapService.cs
- libs/SimpleMQ/Services/ConsumerMessageDispatcher.cs
- libs/SimpleMQ/Services/ConnectionService.cs
- libs/SimpleMQ/Services/BasePublisherService.cs
- libs/SimpleMQ/Options/MessageBrokerConnectionOptions.cs
- libs/SimpleMQ/Options/PublishMessageOptions.cs
Non-Negotiable Rules For This Repo
- Channel strategy
- Keep one channel per queue in bootstrap runtime.
- Do not regress to one channel per handler unless explicitly requested.
- Invocation strategy
- Keep compiled delegates for consumer invocation.
- Avoid reflection invocation in per-message hot paths.
- DI and scope
- Resolve consumer handler instances inside a per-message async scope.
- Preserve correct scoped dependency lifetimes.
- Ack and nack semantics
- When autoAck is false, use explicit ack on success and nack on failure.
- When autoAck is true, never attempt nack.
- Shutdown behavior
- Track consumer tags.
- Cancel subscriptions before closing channels.
- Unsubscribe event handlers and dispose channels defensively.
- Connection lifecycle
- Keep async-first connection handling.
- Keep disposal guards and avoid use-after-dispose behavior.
- Options safety
- Keep startup validation for MessageBrokerConnectionOptions.
- Keep sane defaults for local development.
Edit Strategy
When asked to change behavior:
- Locate the responsibility boundary first:
- Registration and discovery: AddSimpleMQ or ConsumerRegistrationBuilder
- Runtime orchestration: MQBootstrapService
- Per-message processing: ConsumerMessageDispatcher
- Broker connection lifecycle: ConnectionService
- Publish metadata and serialization behavior: BasePublisherService
-
Prefer targeted edits over broad rewrites.
-
If introducing a new concern, prefer extraction into a dedicated service instead of growing existing orchestrators.
-
Preserve public API shape when possible. If API changes are required, keep compatibility wrappers where feasible.
Performance Guidelines
- Avoid extra allocations in message-processing loops when possible.
- Avoid repeated reflection work at runtime.
- Avoid creating channels per message.
- Keep logging meaningful but do not excessively log large payload content.
Reliability Checklist Before Finalizing
- Build/error check passes for libs/SimpleMQ.
- No new nullable warnings from touched files.
- AutoAck false path: success ack and failure nack remain correct.
- AutoAck true path: no nack call path introduced.
- Subscriptions can be cancelled and channels closed during stop.
- Connection service still behaves safely under concurrent open and dispose scenarios.
Suggested Verification Commands
- dotnet build libs/SimpleMQ/SimpleMQ.csproj
- dotnet build monorepo-dotnet.sln
Review Mindset For SimpleMq
When asked for review, prioritize findings in this order:
- Message loss or duplicate risk
- Ack and nack correctness
- Resource leak or shutdown deadlock risk
- Concurrency races in connection or channel lifecycle
- Hot-path performance regressions
- API compatibility and developer ergonomics