Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/rabbitmq.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
],

'options' => [
'queue' => [
'durable' => true,
'auto_delete' => false,
],
],

/*
Expand Down
30 changes: 30 additions & 0 deletions src/Queue/Connection/ConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public static function make(array $config = []): AMQPConnectionConfig

self::getHostFromConfig($connectionConfig, $config);
self::getHeartbeatFromConfig($connectionConfig, $config);
self::getKeepAliveFromConfig($connectionConfig, $config);
self::getNetworkProtocolFromConfig($connectionConfig, $config);
self::getTimeoutFromConfig($connectionConfig, $config);
});
}

Expand Down Expand Up @@ -93,10 +95,38 @@ protected static function getHeartbeatFromConfig(AMQPConnectionConfig $connectio
}
}

protected static function getKeepAliveFromConfig(AMQPConnectionConfig $connectionConfig, array $config): void
{
$keepAlive = Arr::get($config, self::CONFIG_OPTIONS.'.keep_alive');

if (is_bool($keepAlive)) {
$connectionConfig->setKeepalive($keepAlive);
}
}

protected static function getNetworkProtocolFromConfig(AMQPConnectionConfig $connectionConfig, array $config): void
{
if ($networkProtocol = Arr::get($config, 'network_protocol')) {
$connectionConfig->setNetworkProtocol($networkProtocol);
}
}

protected static function getTimeoutFromConfig(AMQPConnectionConfig $connectionConfig, array $config): void
{
if ($connectionTimeout = Arr::get($config, 'connection_timeout')) {
$connectionConfig->setConnectionTimeout($connectionTimeout);
}

if ($readTimeout = Arr::get($config, 'read_timeout')) {
$connectionConfig->setReadTimeout($readTimeout);
}

if ($writeTimeout = Arr::get($config, 'write_timeout')) {
$connectionConfig->setWriteTimeout($writeTimeout);
}

if ($channelRPCTimeout = Arr::get($config, 'channel_rpc_timeout')) {
$connectionConfig->setChannelRPCTimeout($channelRPCTimeout);
}
}
}
12 changes: 10 additions & 2 deletions src/Queue/RabbitMQQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ public function laterRaw($delay, string $payload, $queue = null, int $attempts =

$destination = $this->getQueue($queue).'.delay.'.$ttl;

$this->declareQueue($destination, true, false, $this->getDelayQueueArguments($this->getQueue($queue), $ttl));
$options = $this->config->getOptions();
$durable = Arr::get($options, 'durable') ?: true;
$autoDelete = Arr::get($options, 'auto_delete') ?: false;
Comment on lines +173 to +174
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use 3rd argument of Arr::get()?

$durable = Arr::get($options, 'durable', true);
$autoDelete = Arr::get($options, 'auto_delete', false);


$this->declareQueue($destination, $durable, $autoDelete, $this->getDelayQueueArguments($this->getQueue($queue), $ttl));

[$message, $correlationId] = $this->createMessage($payload, $attempts);

Expand Down Expand Up @@ -717,7 +721,11 @@ protected function declareDestination(string $destination, string $exchange = nu
}

// Create a queue for amq.direct publishing.
$this->declareQueue($destination, true, false, $this->getQueueArguments($destination));
$options = $this->config->getOptions();
$durable = Arr::get($options, 'durable') ?: true;
$autoDelete = Arr::get($options, 'auto_delete') ?: false;
Comment on lines +725 to +726
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use 3rd argument of Arr::get()?

$durable = Arr::get($options, 'durable', true);
$autoDelete = Arr::get($options, 'auto_delete', false);


$this->declareQueue($destination, $durable, $autoDelete, $this->getQueueArguments($destination));
}

/**
Expand Down