|
| 1 | +# stompman Project Context |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +stompman is a modern, asynchronous Python client for the STOMP (Simple Text Oriented Messaging Protocol) messaging protocol. It provides a typed, modern, and comprehensible API for working with STOMP-compatible message brokers like ActiveMQ Artemis and ActiveMQ Classic. |
| 6 | + |
| 7 | +The project consists of two main packages: |
| 8 | +1. `stompman` - The core STOMP client library |
| 9 | +2. `faststream-stomp` - A FastStream broker implementation for STOMP |
| 10 | + |
| 11 | +## Key Features |
| 12 | + |
| 13 | +- Fully asynchronous implementation using Python's asyncio |
| 14 | +- Modern, typed API with comprehensive type hints |
| 15 | +- Automatic connection management with reconnection capabilities |
| 16 | +- Support for transactions, subscriptions, and message acknowledgment |
| 17 | +- Built-in heartbeat support for connection health monitoring |
| 18 | +- Integration with FastStream for declarative message handling |
| 19 | +- Compatible with STOMP 1.2 protocol specification |
| 20 | +- Tested with ActiveMQ Artemis and ActiveMQ Classic |
| 21 | + |
| 22 | +## Project Structure |
| 23 | + |
| 24 | +``` |
| 25 | +stompman/ |
| 26 | +├── packages/ |
| 27 | +│ ├── stompman/ # Core STOMP client library |
| 28 | +│ │ ├── stompman/ # Main source code |
| 29 | +│ │ └── test_stompman/ # Unit and integration tests |
| 30 | +│ └── faststream-stomp/ # FastStream broker implementation |
| 31 | +│ ├── faststream_stomp/ # Main source code |
| 32 | +│ └── test_faststream_stomp/ # Unit and integration tests |
| 33 | +├── examples/ # Usage examples |
| 34 | +├── docker-compose.yml # Development environment with ActiveMQ containers |
| 35 | +└── Justfile # Project commands and workflows |
| 36 | +``` |
| 37 | + |
| 38 | +## Core Components (stompman package) |
| 39 | + |
| 40 | +### Main Classes |
| 41 | + |
| 42 | +- `Client` - The main entry point for interacting with STOMP servers |
| 43 | +- `ConnectionParameters` - Configuration for connecting to STOMP servers |
| 44 | +- `Heartbeat` - Configuration for connection heartbeats |
| 45 | + |
| 46 | +### Key Methods |
| 47 | + |
| 48 | +- `Client.send()` - Send messages to destinations |
| 49 | +- `Client.subscribe()` - Subscribe to destinations with automatic ACK/NACK handling |
| 50 | +- `Client.subscribe_with_manual_ack()` - Subscribe with manual ACK/NACK control |
| 51 | +- `Client.begin()` - Start a transaction context manager |
| 52 | +- `Client.is_alive()` - Check connection health |
| 53 | + |
| 54 | +### Error Handling |
| 55 | + |
| 56 | +- `FailedAllConnectAttemptsError` - Raised when all connection attempts fail |
| 57 | +- `FailedAllWriteAttemptsError` - Raised when writes fail after all retries |
| 58 | +- Various other specific error types for different failure scenarios |
| 59 | + |
| 60 | +## FastStream Integration (faststream-stomp package) |
| 61 | + |
| 62 | +Provides a FastStream broker implementation that allows using FastStream's declarative approach with STOMP: |
| 63 | + |
| 64 | +- `StompBroker` - Main broker class |
| 65 | +- Decorators for subscribers and publishers |
| 66 | +- Testing utilities with `TestStompBroker` |
| 67 | + |
| 68 | +## Development Environment |
| 69 | + |
| 70 | +The project uses Docker Compose to provide a development environment with: |
| 71 | +- ActiveMQ Artemis on port 9000 |
| 72 | +- ActiveMQ Classic on port 9001 |
| 73 | + |
| 74 | +## Building and Running |
| 75 | + |
| 76 | +### Prerequisites |
| 77 | + |
| 78 | +- Python 3.11 or newer |
| 79 | +- uv (package manager) |
| 80 | +- Docker and Docker Compose (for development environment) |
| 81 | + |
| 82 | +### Setup |
| 83 | + |
| 84 | +```bash |
| 85 | +# Install dependencies |
| 86 | +just install |
| 87 | + |
| 88 | +# Or manually: |
| 89 | +uv lock --upgrade |
| 90 | +uv sync --all-extras --all-packages --frozen |
| 91 | +``` |
| 92 | + |
| 93 | +### Running Tests |
| 94 | + |
| 95 | +```bash |
| 96 | +# Run fast tests (unit tests only) |
| 97 | +just test-fast |
| 98 | + |
| 99 | +# Run all tests (including integration tests with Docker) |
| 100 | +just test |
| 101 | + |
| 102 | +# Run tests with specific arguments |
| 103 | +just test-fast -k "test_specific_feature" |
| 104 | +``` |
| 105 | + |
| 106 | +### Code Quality |
| 107 | + |
| 108 | +```bash |
| 109 | +# Run linters |
| 110 | +just lint |
| 111 | + |
| 112 | +# Check types |
| 113 | +just check-types |
| 114 | + |
| 115 | +# Format code |
| 116 | +uv run ruff format . |
| 117 | +``` |
| 118 | + |
| 119 | +### Running Examples |
| 120 | + |
| 121 | +```bash |
| 122 | +# Start ActiveMQ Artemis |
| 123 | +just run-artemis |
| 124 | + |
| 125 | +# Run consumer example |
| 126 | +just run-consumer |
| 127 | + |
| 128 | +# Run producer example |
| 129 | +just run-producer |
| 130 | +``` |
| 131 | + |
| 132 | +## Development Conventions |
| 133 | + |
| 134 | +### Code Style |
| 135 | + |
| 136 | +- Strict adherence to type hints with mypy in strict mode |
| 137 | +- Code formatting with ruff (line length 120) |
| 138 | +- Comprehensive unit and integration tests |
| 139 | +- Modern Python features (3.11+) encouraged |
| 140 | + |
| 141 | +### Testing |
| 142 | + |
| 143 | +- Unit tests in `test_stompman/` directory |
| 144 | +- Integration tests that require Docker containers |
| 145 | +- Property-based testing with hypothesis |
| 146 | +- Test coverage reporting enabled |
| 147 | + |
| 148 | +### CI/CD |
| 149 | + |
| 150 | +- Automated testing on multiple platforms |
| 151 | +- Type checking and linting in CI pipeline |
| 152 | +- Automated publishing to PyPI |
| 153 | + |
| 154 | +## Common Development Tasks |
| 155 | + |
| 156 | +1. **Adding a new feature**: |
| 157 | + - Implement in the appropriate module under `stompman/` |
| 158 | + - Add unit tests in `test_stompman/` |
| 159 | + - Update documentation in docstrings and README if needed |
| 160 | + |
| 161 | +2. **Fixing a bug**: |
| 162 | + - Write a failing test that reproduces the issue |
| 163 | + - Fix the implementation |
| 164 | + - Verify the test now passes |
| 165 | + |
| 166 | +3. **Updating dependencies**: |
| 167 | + - Modify `pyproject.toml` files |
| 168 | + - Run `uv lock --upgrade` to update lock files |
| 169 | + |
| 170 | +4. **Running integration tests**: |
| 171 | + - Ensure Docker is running |
| 172 | + - Run `just test` to start containers and run tests |
0 commit comments