Closed jeyfang0110 closed 1 year ago
最近在看rabbitmq相关的组件,在尝试使用这个组件时,关于helpers下的两个方法有个疑问,如下
* 同步生产 * @param FastBuilder $builder * @param string $body * @param array|null $headers * @param bool $close * @return bool */ function sync_publish(FastBuilder $builder, string $body, ?array $headers = null, bool $close = false) : bool { $message = $builder->getMessage(); if( ($message->getExchangeType() !== Constants::DELAYED and $headers['x-delay'] ?? 1) or ($message->getExchangeType() === Constants::DELAYED and !($headers['x-delay'] ?? 0)) ){ throw new WebmanRabbitMQException('Invalid publish. '); } $message->setBody($body); if($headers !== null){ $message->setHeaders(array_merge($message->getHeaders(), $headers)); } return $builder->syncConnection()->publish($message, $close); }
若这里$builder是普通队列,则$message的ExchangeType是Constants::DIRECT,当$headers不传递时,默认为null,那这里不是始终抛WebmanRabbitMQException了?
$builder
$message
$headers
null
WebmanRabbitMQException
已修复
最近在看rabbitmq相关的组件,在尝试使用这个组件时,关于helpers下的两个方法有个疑问,如下
若这里
$builder
是普通队列,则$message
的ExchangeType是Constants::DIRECT,当$headers
不传递时,默认为null
,那这里不是始终抛WebmanRabbitMQException
了?