怎么单独设置 x-expires属性呢
Open
Nobody has claimed this yet.
status:to be verified
- Dominant language
- PHP
- Stars
- 1.1k
- Forks
- 285
- Avg merge
- 5d 3h
- Merged PRs (30d)
- 2
Description
现在 在 namespace Enqueue\AmqpTools;的RabbitMqDlxDelayStrategy下没设置,只能改这块的代码吗
<?php
namespace Enqueue\AmqpTools;
use Interop\Amqp\AmqpContext;
use Interop\Amqp\AmqpDestination;
use Interop\Amqp\AmqpMessage;
use Interop\Amqp\AmqpQueue;
use Interop\Amqp\AmqpTopic;
use Interop\Queue\InvalidDestinationException;
class RabbitMqDlxDelayStrategy implements DelayStrategy
{
/**
* {@inheritdoc}
*/
public function delayMessage(AmqpContext $context, AmqpDestination $dest, AmqpMessage $message, $delayMsec)
{
$properties = $message->getProperties();
// The x-death header must be removed because of the bug in RabbitMQ.
// It was reported that the bug is fixed since 3.5.4 but I tried with 3.6.1 and the bug still there.
// https://github.com/rabbitmq/rabbitmq-server/issues/216
unset($properties['x-death']);
$delayMessage = $context->createMessage($message->getBody(), $properties, $message->getHeaders());
$delayMessage->setRoutingKey($message->getRoutingKey());
if ($dest instanceof AmqpTopic) {
$routingKey = $message->getRoutingKey() ? '.'.$message->getRoutingKey() : '';
$name = sprintf('enqueue.%s%s.%s.x.delay', $dest->getTopicName(), $routingKey, $delayMsec);
$delayQueue = $context->createQueue($name);
$delayQueue->addFlag(AmqpTopic::FLAG_DURABLE);
$delayQueue->setArgument('x-message-ttl', $delayMsec);
// $delayQueue->setArgument('x-expires', $delayMsec+1000);
$delayQueue->setArgument('x-dead-letter-exchange', $dest->getTopicName());
$delayQueue->setArgument('x-dead-letter-routing-key', (string) $delayMessage->getRoutingKey());
} elseif ($dest instanceof AmqpQueue) {
$delayQueue = $context->createQueue('enqueue.'.$dest->getQueueName().'.'.$delayMsec.'.delayed');
$delayQueue->addFlag(AmqpTopic::FLAG_DURABLE);
$delayQueue->setArgument('x-message-ttl', $delayMsec);
$delayQueue->setArgument('x-dead-letter-exchange', '');
$delayQueue->setArgument('x-dead-letter-routing-key', $dest->getQueueName());
} else {
throw new InvalidDestinationException(sprintf('The destination must be an instance of %s but got %s.',
AmqpTopic::class.'|'.AmqpQueue::class,
get_class($dest)
));
}
$context->declareQueue($delayQueue);
$context->createProducer()->send($delayQueue, $delayMessage);
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate RabbitMqDlxDelayStrategy and read delayMessage, especially the commented x-expires line and the separate topic and queue branches. Determine whether the existing API provides a way to configure this queue argument without editing the strategy directly; done means the supported configuration path is clear and verified against RabbitMQ queue declaration behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, rabbitmq
- Domain
- backend, distributed-systems
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100