|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types = 1); |
|
3
|
|
|
|
|
4
|
|
|
namespace Innmind\AMQP\Model\Basic; |
|
5
|
|
|
|
|
6
|
|
|
final class Publish |
|
7
|
|
|
{ |
|
8
|
|
|
private $message; |
|
9
|
|
|
private $exchange = ''; |
|
10
|
|
|
private $routingKey = ''; |
|
11
|
|
|
private $mandatory = false; |
|
12
|
|
|
private $immediate = false; |
|
13
|
|
|
|
|
14
|
70 |
|
public function __construct(Message $message) |
|
15
|
|
|
{ |
|
16
|
70 |
|
$this->message = $message; |
|
17
|
70 |
|
} |
|
18
|
|
|
|
|
19
|
40 |
|
public function to(string $exchange): self |
|
20
|
|
|
{ |
|
21
|
40 |
|
$self = clone $this; |
|
22
|
40 |
|
$self->exchange = $exchange; |
|
23
|
|
|
|
|
24
|
40 |
|
return $self; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
2 |
|
public function toDefaultExchange(): self |
|
28
|
|
|
{ |
|
29
|
2 |
|
$self = clone $this; |
|
30
|
2 |
|
$self->exchange = ''; |
|
31
|
|
|
|
|
32
|
2 |
|
return $self; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
8 |
|
public function withRoutingKey(string $key): self |
|
36
|
|
|
{ |
|
37
|
8 |
|
$self = clone $this; |
|
38
|
8 |
|
$self->routingKey = $key; |
|
39
|
|
|
|
|
40
|
8 |
|
return $self; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* This will raise an error if the message can't be routed |
|
45
|
|
|
*/ |
|
46
|
4 |
|
public function flagAsMandatory(): self |
|
47
|
|
|
{ |
|
48
|
4 |
|
$self = clone $this; |
|
49
|
4 |
|
$self->mandatory = true; |
|
50
|
|
|
|
|
51
|
4 |
|
return $self; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* This will fail silently if the message can't be routed |
|
56
|
|
|
*/ |
|
57
|
2 |
|
public function flagAsNotMandatory(): self |
|
58
|
|
|
{ |
|
59
|
2 |
|
$self = clone $this; |
|
60
|
2 |
|
$self->mandatory = false; |
|
61
|
|
|
|
|
62
|
2 |
|
return $self; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* This will raise an error if the message can't be delivered immediately |
|
67
|
|
|
*/ |
|
68
|
4 |
|
public function flagAsImmediate(): self |
|
69
|
|
|
{ |
|
70
|
4 |
|
$self = clone $this; |
|
71
|
4 |
|
$self->immediate = true; |
|
72
|
|
|
|
|
73
|
4 |
|
return $self; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* This will fail silently if the message can't be delivered immediately |
|
78
|
|
|
*/ |
|
79
|
2 |
|
public function flagAsNotImmediate(): self |
|
80
|
|
|
{ |
|
81
|
2 |
|
$self = clone $this; |
|
82
|
2 |
|
$self->immediate = false; |
|
83
|
|
|
|
|
84
|
2 |
|
return $self; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
58 |
|
public function message(): Message |
|
88
|
|
|
{ |
|
89
|
58 |
|
return $this->message; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
60 |
|
public function exchange(): string |
|
93
|
|
|
{ |
|
94
|
60 |
|
return $this->exchange; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
60 |
|
public function routingKey(): string |
|
98
|
|
|
{ |
|
99
|
60 |
|
return $this->routingKey; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
56 |
|
public function mandatory(): bool |
|
103
|
|
|
{ |
|
104
|
56 |
|
return $this->mandatory; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
56 |
|
public function immediate(): bool |
|
108
|
|
|
{ |
|
109
|
56 |
|
return $this->immediate; |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|