Compare commits
6 commits
Author | SHA1 | Date | |
---|---|---|---|
|
a06ec22341 | ||
|
f15d9a2a86 | ||
|
a104eebf2a | ||
|
3f87618424 | ||
|
5520c4ca68 | ||
|
ac0a1ae95d |
3 changed files with 10 additions and 4 deletions
|
@ -105,7 +105,7 @@ abstract class CommandMessage
|
||||||
public function __serialize(): array
|
public function __serialize(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'command' => $this->getCommandName(),
|
'commandName' => $this->getCommandName(),
|
||||||
'arguments' => $this->getArguments(),
|
'arguments' => $this->getArguments(),
|
||||||
'options' => $this->getOptions()
|
'options' => $this->getOptions()
|
||||||
];
|
];
|
||||||
|
|
|
@ -21,9 +21,15 @@ class LockableMessageMiddleware implements MiddlewareInterface
|
||||||
*/
|
*/
|
||||||
private $lockFactory;
|
private $lockFactory;
|
||||||
|
|
||||||
public function __construct(LockFactory $lockFactory)
|
/**
|
||||||
|
* @var int|null
|
||||||
|
*/
|
||||||
|
private $ttl;
|
||||||
|
|
||||||
|
public function __construct(LockFactory $lockFactory, int $ttl = null)
|
||||||
{
|
{
|
||||||
$this->lockFactory = $lockFactory;
|
$this->lockFactory = $lockFactory;
|
||||||
|
$this->ttl = $ttl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,7 +45,7 @@ class LockableMessageMiddleware implements MiddlewareInterface
|
||||||
$message = $envelope->getMessage();
|
$message = $envelope->getMessage();
|
||||||
|
|
||||||
if ($envelope->all(ReceivedStamp::class) && $message instanceof LockableMessage) {
|
if ($envelope->all(ReceivedStamp::class) && $message instanceof LockableMessage) {
|
||||||
$lock = $this->lockFactory->createLock($this->objectHash($message), null);
|
$lock = $this->lockFactory->createLock($this->objectHash($message), $this->ttl);
|
||||||
if (!$lock->acquire()) {
|
if (!$lock->acquire()) {
|
||||||
return $envelope;
|
return $envelope;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
"symfony/framework-bundle": "^4.0|^5.0",
|
"symfony/framework-bundle": "^4.0|^5.0",
|
||||||
"symfony/serializer": "^5.2",
|
"symfony/serializer": "^5.2",
|
||||||
"symfony/http-kernel": "^4.0|^5.0",
|
"symfony/http-kernel": "^4.0|^5.0",
|
||||||
"symfony/validator": "^4.0|^5.0",
|
"symfony/validator": "^4.0|^5.3",
|
||||||
"symfony/security-guard": "^4.0|^5.0",
|
"symfony/security-guard": "^4.0|^5.0",
|
||||||
"symfony/console": "^5.2",
|
"symfony/console": "^5.2",
|
||||||
"symfony/messenger": "^5.2",
|
"symfony/messenger": "^5.2",
|
||||||
|
|
Loading…
Add table
Reference in a new issue