Start a consumer on an existing connection

@return void
344653
public function start()
    {
        if ($this->restart) {
            echo 'Restarting consumer.' . PHP_EOL;
            $this->restart = false;
        } else {
            echo 'Starting consumer.' . PHP_EOL;
        }

        $exchange = 'router';
        $queue    = 'msgs';

        $this->channel = $this->connection->channel();
        $this->channel->queue_declare($queue, false, true, false, false);
        $this->channel->exchange_declare($exchange, AMQPExchangeType::DIRECT, false, true, false);
        $this->channel->queue_bind($queue, $exchange);
        $this->channel->basic_consume(
            $queue,
            $this->consumerTag,
            false,
            false,
            false,
            false,
            [$this,'messageHandler'],
            null,
            ['x-cancel-on-ha-failover' => ['t', true]] // fail over to another node
        );

        echo 'Enter wait.' . PHP_EOL;
        while ($this->channel->is_consuming()) {
            $this->channel->wait();
        }
        echo 'Exit wait.' . PHP_EOL;
    }
1349554
public function beginTransaction()
    {
        try {
            $this->connection->beginTransaction();
        } catch (DBALException $e) {
            throw new OrmException("Unable to start transaction.\n" . $e->getMessage(), 0, $e);
        }
    }
615460
public function startup()
	{
		$this->out(__d('Auditable', 'Cake Auditable Shell'));
		$this->hr();

		if (!empty($this->params['connection']))
			$this->connection = $this->params['connection'];
	}
386994
public function beginTransaction() {
        // check if a transaction is already active
        if ($this->getConnection()->inTransaction())
            throw new \Exception("Already inside a DB transaction. You need to commit it before beginning a new one.");

        try {
            // No need to check for the connection again
            $this->getConnection(false)->beginTransaction();
        } catch (Exception $_e) {
            throw new \Exception("Error while beginning DB transaction: ".$pe->getMessage());
        }
    }
642307
protected function connect()
	{
		$this->context = new ZMQContext($this->ioThreadTotal, $this->persistent);
		$this->socket  = $this->context->getSocket($this->socketType, $this->persistenceKey);
	    $this->socket->connect($this->connection);
	}
1312858
def start(self):
        """"""
        with self._operational_lock:
            ready = threading.Event()
            thread = threading.Thread(
                name=_BIDIRECTIONAL_CONSUMER_NAME,
                target=self._thread_main,
                args=(ready,)
            )
            thread.daemon = True
            thread.start()
            # Other parts of the code rely on `thread.is_alive` which
            # isn't sufficient to know if a thread is active, just that it may
            # soon be active. This can cause races. Further protect
            # against races by using a ready event and wait on it to be set.
            ready.wait()
            self._thread = thread
            _LOGGER.debug("Started helper thread %s", thread.name)
1092629
public function open()
    {
        // Connect the socket.
        if (@!socket_connect($this->socket, $this->host, $this->port)) {
         Logger::get()->error(socket_strerror(socket_last_error()));
            throw new Exception('Socket connection error: ' . socket_strerror(socket_last_error()));
        }
    }
223473
public function start()
    {
        $this->workerHandlerReady = true;
        $this->serviceStreamReady = true;
        $this->sendToService(new ActionListRequest());
    }
355997
public function start() {
        if (!$this->isStarted) {
            $this->generateIpcServer();
            $this->isStarted = true;
            for ($i=0;$i<$this->poolSizeMin;$i++) {
                $this->spawnWorker();
            }
            $this->registerTaskTimeoutWatcher();
        }

        return $this;
    }
131307
private function start()
    {
        $timer = $this->getStopwatchInstance();
        $timer->start($this->name, $this->category);
    }
64273
private function connect()
    {
        $this->conn = parent::getConn();
        $this->create = $this->conn->prepare($this->create);
    }
61706
def on_consume_ready(self, connection, channel, consumers, **kwargs):
        
        if not self._consumers_ready.ready():
            _log.debug('consumer started %s', self)
            self._consumers_ready.send(None)
1008232
public function start()
	{
		if ($this->getState() === 'active')
		{
			return;
		}

		$this->_start();

		$this->setState('active');

		// Initialise the session
		$this->_setCounter();
		$this->_setTimers();

		// Perform security checks
		$this->_validate();

		if ($this->dispatcher instanceof DispatcherInterface)
		{
			$this->dispatcher->triggerEvent('onAfterSessionStart');
		}
	}
513605
def start(self):
        '''
        
        '''
        log.debug('Creating the consumer using the bootstrap servers: %s and the group ID: %s',
                  self.bootstrap_servers,
                  self.group_id)
        try:
            self.consumer = kafka.KafkaConsumer(bootstrap_servers=self.bootstrap_servers,
                                                group_id=self.group_id)
        except kafka.errors.NoBrokersAvailable as err:
            log.error(err, exc_info=True)
            raise ListenerException(err)
        log.debug('Subscribing to the %s topic', self.topic)
        self.consumer.subscribe(topics=[self.topic])
1101645
def create_consumer(self):
        """"""
        with self.connection_pool.acquire(block=True) as conn:
            yield self.consumer(conn)
275353
public function start()
    {
        $__scope = $this->_runHooks($this->_startHooks);
        extract($__scope);
        
        $this->_write($this->_socket, self::READY);
        
        /* Note the naming of the local variables due to shared scope with the user here */
        for (;;) {
            declare (ticks = 1);
            // don't exit on ctrl-c
            pcntl_signal(SIGINT, SIG_IGN, true);
            
            $this->_cancelled = false;
            
            $__input = $this->_transform($this->_read($this->_socket));
            
            if ($__input === null) {
                continue;
            }
            
            $__response = self::DONE;
            
            $this->_ppid = posix_getpid();
            $this->_pid  = pcntl_fork();
            
            if ($this->_pid < 0) {
                throw new \RuntimeException('Failed to fork child labourer');
            } elseif ($this->_pid > 0) {
                // kill the child on ctrl-c
                pcntl_signal(SIGINT, array(
                    $this,
                    'cancelOperation'
                ), true);
                pcntl_waitpid($this->_pid, $__status);
                
                if (!$this->_cancelled && $__status != (self::ABNORMAL_EXIT << 8)) {
                    $__response = self::EXITED;
                } else {
                    $this->_runHooks($this->_failureHooks);
                    $__response = self::FAILED;
                }
            } else {
                // if the user has installed a custom exception handler, install a new
                // one which calls it and then (if the custom handler didn't already exit)
                // exits with the correct status.
                // If not, leave the exception handler unset; we'll display
                // an uncaught exception error and carry on.
                $__oldexh = set_exception_handler(array(
                    $this,
                    'delegateExceptionHandler'
                ));
                if ($__oldexh && !$this->_userExceptionHandler) {
                    $this->_userExceptionHandler = $__oldexh; // save the old handler (once)
                } else {
                    restore_exception_handler();
                }
                
                // undo ctrl-c signal handling ready for user code execution
                pcntl_signal(SIGINT, SIG_DFL, true);
                $__pid = posix_getpid();
                
                $__result = eval($__input);
                
                if (posix_getpid() != $__pid) {
                    // whatever the user entered caused a forked child
                    // (totally valid, but we don't want that child to loop and wait for input)
                    exit(0);
                }
                
                if (preg_match('/\s*return\b/i', $__input)) {
                    fwrite(STDOUT, sprintf("%s\n", $this->_inspector->inspect($__result)));
                }
                $this->_expungeOldWorker();
            }
            
            $this->_write($this->_socket, $__response);
            
            if ($__response == self::EXITED) {
                exit(0);
            }
        }
    }
217025
private function start()
    {
        # Starting session.
        # Here making session active to every request.
        new Session();

        $this->setBaseURL();
        $this->setRequestURI();
        $this->fetchRouteRules();
        $this->establishConnection();
        $this->locateMethod();
        $this->invokeMethod();
    }