Logo di Messenger Async

Messenger Async

Community
fatonh
messenger-async

Use when implementing async processing, CQRS, or event-driven flows in Symfony with the Messenger component — message/handler pairs, transports, routing, retries, failure queues, and the outbox pattern. Use when the task mentions Messenger, message bus, async, queue, command/query handler, or background job.

Panoramica

Autorefatonh
Repositorysymfony-skills
Nome della skillmessenger-async
Stelle
36
Fork
3
File inclusi
Solo istruzioni
LicenzaMIT
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • Tutto nelle istruzioni

    Tutto ciò che serve al modello è nelle istruzioni: nessun file aggiuntivo da sincronizzare.

  • Open source

    Pubblicata da fatonh su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Messenger Async in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/fatonh/symfony-skills/tree/main/skills/messenger-async
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Nuova skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella nella cartella delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/fatonh/symfony-skills.git /tmp/symfony-skills
mkdir -p .claude/skills
cp -r /tmp/symfony-skills/skills/messenger-async .claude/skills/messenger-async
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Messenger Async in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Messenger Async non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Messenger Async non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Symfony Messenger (Async & CQRS)

Message + handler pairs

A message is a plain, immutable DTO. A handler is a class with #[AsMessageHandler] and an __invoke() typed to the message. One handler per command.

php
// Command message — immutable intent
final readonly class PlaceOrder
{
    /** @param array<int, array{productId: string, quantity: int}> $items */
    public function __construct(
        public string $customerEmail,
        public array $items,
    ) {}
}
php
// Handler
#[AsMessageHandler]
final class PlaceOrderHandler
{
    public function __construct(private readonly OrderService $orders) {}

    public function __invoke(PlaceOrder $command): void
    {
        $this->orders->placeOrder($command);
    }
}
php
// Dispatch from a controller/service
$this->bus->dispatch(new PlaceOrder($request->customerEmail, $request->items));

Separate buses for command / query / event (CQRS)

yaml
# config/packages/messenger.yaml
framework:
    messenger:
        default_bus: command.bus
        buses:
            command.bus:                          # one handler, returns void/id
                middleware: [validation, doctrine_transaction]
            query.bus:                            # one handler, returns a read model
            event.bus:                            # zero-or-many handlers, fan-out
                default_middleware: allow_no_handlers
  • Commands: change state, exactly one handler, named imperatively (PlaceOrder).
  • Queries: return data, one handler, no side effects (GetOrderSummary).
  • Events: something happened, many subscribers allowed, past tense (OrderPlaced).

Transports & routing

Sync by default; route the slow/external work to an async transport.

yaml
framework:
    messenger:
        transports:
            async:
                dsn: '%env(MESSENGER_TRANSPORT_DSN)%'   # doctrine:// , amqp:// , redis://
                retry_strategy:
                    max_retries: 3
                    delay: 1000
                    multiplier: 2                       # exponential backoff
            failed: 'doctrine://default?queue_name=failed'

        failure_transport: failed

        routing:
            App\Message\Command\PlaceOrder: async
            App\Message\Event\OrderPlaced: async

Run a worker to consume async messages:

bash
php bin/console messenger:consume async --time-limit=3600 --memory-limit=256M

In production, supervise the worker (systemd / Supervisor) and recycle it (--time-limit) to avoid leaks.

Retries & the failure transport

  • Transient failures (network blip) → automatic retry with backoff.
  • Permanent failures land in the failed transport instead of being lost.
bash
php bin/console messenger:failed:show          # inspect
php bin/console messenger:failed:retry         # replay after a fix
php bin/console messenger:failed:remove <id>   # discard

Throw UnrecoverableMessageHandlingException to skip retries for errors that will never succeed (bad payload, business rule violation).

Idempotency

Async messages can be delivered more than once (retry, at-least-once transports). Handlers must be idempotent — process by a natural key and no-op if already done.

php
public function __invoke(ChargePayment $message): void
{
    if ($this->payments->existsByIdempotencyKey($message->idempotencyKey)) {
        return; // already processed — safe to receive twice
    }
    $this->gateway->charge($message);
}

Outbox pattern: atomic DB write + reliable dispatch

Dispatching a message after flush() can lose it if the process dies in between; dispatching before can emit an event for a transaction that then rolls back. The Doctrine transport with the DispatchAfterCurrentBusMiddleware (built in) handles the in-bus case; for cross-process reliability, persist the message in the same transaction (outbox) and let a relay/worker publish it.

php
// Dispatch within the handler's transaction; the transport row commits atomically.
$this->bus->dispatch(new OrderPlaced($order->getId()), [new DispatchAfterCurrentBusStamp()]);

Conventions

  • Messages are immutable, serializable DTOs — no entities, no closures, no services inside them.
  • Pass IDs, not Doctrine entities — the entity may be stale by the time the worker runs; reload it in the handler.
  • Keep handlers thin — delegate to an application service (see layered-architecture).
  • One handler per command; events may have many.
  • Name by intent: commands imperative, events past tense.

Gotchas

  • Agent puts a Doctrine entity inside a message — pass the ID and reload in the handler; entities don't serialize cleanly and go stale.
  • Agent writes non-idempotent handlers — async is at-least-once; guard with an idempotency key.
  • Agent never configures a failure_transport — failed messages vanish; add the failed transport.
  • Agent retries permanent failures forever — throw UnrecoverableMessageHandlingException for non-retryable errors.
  • Agent dispatches an event before flush() (or after, unguarded) — use DispatchAfterCurrentBusStamp / outbox for atomicity.
  • Agent runs handlers synchronously for slow/external work — route those messages to an async transport.
  • Agent forgets the worker needs supervising + memory/time limits in prod.
  • Agent puts business logic in the handler — delegate to a service; the handler just adapts the message.

Domande frequenti

Cosa fa la skill IA Messenger Async?

Use when implementing async processing, CQRS, or event-driven flows in Symfony with the Messenger component — message/handler pairs, transports, routing, retries, failure queues, and the outbox pattern. Use when the task mentions Messenger, message bus, async, queue, command/query handler, or background job.

Perché usare Messenger Async su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Messenger Async è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Messenger Async in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/fatonh/symfony-skills/tree/main/skills/messenger-async. TypingMind legge il file SKILL.md e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Messenger Async?

Qualsiasi modello che colleghi in TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Messenger Async?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Messenger Async: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Messenger Async è gratuita?

Sì. È pubblicata su GitHub da fatonh con licenza MIT. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, modelli o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇