private static function build(
        $host,
        $port,
        $user,
        $pass,
        $queueName,
        QueueConsumer $consumer,
        $sync,
        $escapeMode,
        $requeueOnFailure,
        LoggerInterface $logger = null,
        $stopOnFailure = false
    ) {
        $consumer = self::getSerializingConsumer($consumer, $escapeMode);

        $driver = DriverFactory::getDriver([
            'host' => $host,
            'port' => $port,
            'user' => $user,
            'pwd'  => $pass
        ]);

        $builder = new HandlerBuilder($driver);

        if ($sync) {
            $builder->sync($consumer);
        } else {
            $builder->async($consumer);
        }

        if (! $stopOnFailure) {
            $builder->continueOnFailure();
        }

        if (! $requeueOnFailure) {
            $builder->doNotRequeueOnFailure();
        }

        $builder->log(($logger === null) ? new NullLogger() : $logger);

        return new QueueHandlingDaemon($driver, $builder->build(), $queueName);
    }