public function build(QueueConsumer $consumer)
    {
        Assertion::notNull($this->sync, 'You must specify if the handler must be sync or async');

        // Sync
        $handler = $this->sync ?
            new SyncConsumerHandler($consumer, $this->driver) :
            new AsyncConsumerHandler($consumer);
        $handler->setLogger($this->logger);

        // Ack
        $handler = $this->autoAck ?
            $handler :
            new AckHandler($handler, $this->driver, $this->requeueOnFailure);

        // Stop / Continue
        $handler = $this->stopOnFailure ?
            new StopOnExceptionHandler($handler) :
            new ContinueOnExceptionHandler($handler);
        $handler->setLogger($this->logger);

        return $handler;
    }