framework:
    messenger:
        default_bus: command.bus
        # Transports
        transports:
            commands:
                dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
                options:
                    queue_name: commands
            events:
                dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
                options:
                    queue_name: events

        # Buses configuration
        buses:
            command.bus:
                middleware:
                    - validation
                    - doctrine_transaction
            event.bus:
                default_middleware: allow_no_handlers

        # Message routing
        routing:
            # Commands
            'App\Domain\Scraping\Application\Command\ScrapeChapter': commands
            'App\Domain\Manga\Application\Command\FetchMangaChapters': commands
            'App\Domain\Manga\Application\Command\RefreshMangaChapters': commands
            
            # Events spécifiques (pour compatibilité, peuvent être supprimés si tous implémentent AsyncDomainEvent)
            'App\Domain\Scraping\Domain\Event\ChapterScrapingStarted': events
            'App\Domain\Scraping\Domain\Event\ChapterScrapingCompleted': events
            'App\Domain\Scraping\Domain\Event\ChapterScrapingFailed': events
            'App\Domain\Manga\Domain\Event\ChapterReadyForScraping': events
            'App\Domain\Manga\Domain\Event\MangaCreated': events
            'App\Domain\Shared\Domain\Event\ChapterImported': events
            'App\Domain\Shared\Domain\Event\VolumeImported': events

            # Legacy messages (à garder si nécessaire)
            'App\Message\DownloadChapter': commands
            'App\Message\RefreshMetadata': commands
            'App\Message\RefreshAndDownloadChapters': commands

# when@test:
#    framework:
#        messenger:
#            transports:
#                # replace with your transport name here (e.g., my_transport: 'in-memory://')
#                # For more Messenger testing tools, see https://github.com/zenstruck/messenger-test
#                async: 'in-memory://'
