API¶
pico_rabbitmq.decorators ¶
Marker decorators for the two sides of RabbitMQ messaging.
Consumer side: @consumer on a component method subscribes it to a queue; the method receives the JSON-decoded message body.
Publisher side: @publisher on a class of @publish stubs turns it into an injectable component whose methods send their message argument as a JSON body (same generated-implementation idiom as pico-httpx clients).
consumer(queue, *, exchange='', routing_key='', exchange_type='topic') ¶
Subscribe a component method to queue.
With exchange empty the queue receives messages published to the default exchange under its own name. Otherwise the exchange is declared (exchange_type) and the queue bound with routing_key.
Source code in src/pico_rabbitmq/decorators.py
publisher(cls) ¶
Turn a class of @publish stubs into an injectable component.
Source code in src/pico_rabbitmq/decorators.py
publish(*, exchange='', routing_key) ¶
Generate a publishing implementation for a stub method.
The stub's message argument (any JSON-serializable value) is the body. Sync stubs block until the broker confirms; async stubs await it.
Source code in src/pico_rabbitmq/decorators.py
pico_rabbitmq.registrar ¶
Connection owner and dispatcher.
Runs a dedicated asyncio loop in a daemon thread so consumers and publishers work in any app — sync scripts, FastAPI, celery workers — without lifespan wiring. Consumers resolve their component through the container per message (prototype scope = fresh instance per message).
Delivery semantics: ack on success; on exception the message is rejected WITHOUT requeue (log + drop) so a poison message cannot spin the consumer. Configure a dead-letter exchange on the queue if you need to keep failures.