protected function parseConnection($connectionName)
    {
        $connection = null;

        // If user provided the connection name read it directly
        if ($connectionName) {
            if (! $connection = config("queue.connections.$connectionName")) {
                throw new \InvalidArgumentException("Connection '$connectionName' doesn't exist.");
            }
        }

        // Try default connection
        if (! $connection) {
            $defaultConnection = config('queue.default');

            if ('beanstalkd' == config("queue.connections.$defaultConnection.driver")) {
                $connection = config("queue.connections.$defaultConnection");
            }
        }

        // Try first connection that has beanstalkd driver
        if (! $connection) {
            foreach (config('queue.connections') as $connection) {
                if ('beanstalkd' == $connection['driver']) {
                    break;
                }
            }
        }

        if (! empty($connection['host'])) {
            $parsedConfigHost = explode(':', $connection['host']);

            $this->host = $parsedConfigHost[0];

            if (isset($parsedConfigHost[1])) {
                $this->port = $parsedConfigHost[1];
            }
        }

        if (! empty($connection['queue'])) {
            $this->defaultTube = $connection['queue'];
        }
    }