setName(self::NAME); // Add our options, skipping any name the parent already defines to avoid a clash. foreach ($this->rabbitmqOptions() as $option) { if (! $this->getDefinition()->hasOption($option->getName())) { $this->getDefinition()->addOption($option); } } } /** * Parse the RabbitMQ signature DSL into InputOption objects. * * @return array */ protected function rabbitmqOptions(): array { [, , $options] = Parser::parse(self::RABBITMQ_SIGNATURE); return $options; } public function handle(): void { /** @var Consumer $consumer */ $consumer = $this->worker; $consumer->setContainer($this->laravel); $consumer->setName($this->option('name')); $consumer->setConsumerTag($this->consumerTag()); $consumer->setMaxPriority((int) $this->option('max-priority')); $consumer->setPrefetchSize((int) $this->option('prefetch-size')); $consumer->setPrefetchCount((int) $this->option('prefetch-count')); parent::handle(); } protected function consumerTag(): string { if ($consumerTag = $this->option('consumer-tag')) { return $consumerTag; } $consumerTag = implode('_', [ Str::slug(config('app.name', 'laravel')), Str::slug($this->option('name')), md5(serialize($this->options()).Str::random(16).getmypid()), ]); return Str::substr($consumerTag, 0, 255); } }