|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace mcorten87\rabbitmq_api\objects; |
|
4
|
|
|
|
|
5
|
|
|
class QueueArgument extends BaseObject |
|
6
|
|
|
{ |
|
7
|
|
|
/** |
|
8
|
|
|
* @var integer |
|
9
|
|
|
* How long a message published to a queue can live before it is discarded (milliseconds). |
|
10
|
|
|
*/ |
|
11
|
|
|
const MESSAGE_TTL = 'message-ttl'; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @var integer |
|
15
|
|
|
* How long a queue can be unused for before it is automatically deleted (milliseconds). |
|
16
|
|
|
*/ |
|
17
|
|
|
const EXPIRES = 'expires'; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @var integer |
|
21
|
|
|
* How many (ready) messages a queue can contain before it starts to drop them from its head. |
|
22
|
|
|
*/ |
|
23
|
|
|
const MAX_LENGTH = 'max-length'; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var integer |
|
27
|
|
|
* Total body size for ready messages a queue can contain before it starts to drop them from its head. |
|
28
|
|
|
*/ |
|
29
|
|
|
const MAX_BYTES = 'max-length-bytes'; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var string |
|
33
|
|
|
* Name of an exchange to which messages will be republished if they are rejected or expire. |
|
34
|
|
|
*/ |
|
35
|
|
|
const MAX_DEAD_LETTER_EXCHAGE = 'dead-letter-exchange'; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var string |
|
39
|
|
|
* Replacement routing key to use when a message is dead-lettered. If this is not set, the message's original routing key will be used. |
|
40
|
|
|
*/ |
|
41
|
|
|
const MAX_DEAD_LETTER_ROUTING_KEY = 'dead-letter-routing-key'; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @var integer |
|
45
|
|
|
* Maximum number of priority levels for the queue to support; |
|
46
|
|
|
* if not set, the queue will not support message priorities. |
|
47
|
|
|
*/ |
|
48
|
|
|
const MAX_PRIORITY = 'max-priority'; |
|
49
|
|
|
|
|
50
|
|
|
private $argumentName; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @return String |
|
54
|
|
|
*/ |
|
55
|
17 |
|
public function getArgumentName() |
|
56
|
|
|
{ |
|
57
|
17 |
|
return $this->argumentName; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
17 |
|
public function __construct(String $argument, string $value) |
|
61
|
|
|
{ |
|
62
|
17 |
|
$this->argumentName = $argument; |
|
63
|
|
|
|
|
64
|
17 |
|
parent::__construct($value); |
|
65
|
8 |
|
} |
|
66
|
|
|
|
|
67
|
17 |
|
public function validate($value) : bool |
|
68
|
|
|
{ |
|
69
|
17 |
|
if (empty($this->getArgumentName())) { |
|
70
|
1 |
|
return false; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
16 |
|
switch ($this->argumentName) { |
|
74
|
16 |
|
case self::MESSAGE_TTL: |
|
75
|
14 |
|
case self::EXPIRES: |
|
76
|
12 |
|
case self::MAX_LENGTH: |
|
77
|
9 |
|
case self::MAX_BYTES: |
|
78
|
7 |
|
case self::MAX_PRIORITY: |
|
79
|
11 |
|
return is_numeric($this->getValue()) && $this->getValue() >= 0; |
|
80
|
|
|
|
|
81
|
5 |
|
case self::MAX_DEAD_LETTER_EXCHAGE: |
|
82
|
3 |
|
case self::MAX_DEAD_LETTER_ROUTING_KEY: |
|
83
|
4 |
|
return !empty($value); |
|
84
|
|
|
|
|
85
|
|
|
default: |
|
86
|
1 |
|
return false; |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|