-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathTestProducer.php
More file actions
119 lines (104 loc) · 2.31 KB
/
Copy pathTestProducer.php
File metadata and controls
119 lines (104 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
declare(strict_types=1);
namespace Cake\Queue\TestSuite\Transport;
use Cake\Queue\TestSuite\TestQueueClient;
use Interop\Queue\Destination;
use Interop\Queue\Message;
use Interop\Queue\Producer;
/**
* Test Producer
*
* Captures messages instead of sending them to a queue.
*/
class TestProducer implements Producer
{
/**
* Delivery delay
*/
protected ?int $deliveryDelay = null;
/**
* Time to live
*/
protected ?int $timeToLive = null;
/**
* Priority
*/
protected ?int $priority = null;
/**
* Send message
*
* @param \Interop\Queue\Destination $destination Destination
* @param \Interop\Queue\Message $message Message
* @return void
*/
public function send(Destination $destination, Message $message): void
{
TestQueueClient::captureMessage(
$destination,
$message,
$this->deliveryDelay,
$this->timeToLive,
$this->priority,
);
}
/**
* Set delivery delay
*
* @param int|null $deliveryDelay Delay in milliseconds
* @return \Interop\Queue\Producer
*/
public function setDeliveryDelay(?int $deliveryDelay = null): Producer
{
$this->deliveryDelay = $deliveryDelay;
return $this;
}
/**
* Get delivery delay
*
* @return int|null
*/
public function getDeliveryDelay(): ?int
{
return $this->deliveryDelay;
}
/**
* Set priority
*
* @param int|null $priority Priority
* @return \Interop\Queue\Producer
*/
public function setPriority(?int $priority = null): Producer
{
$this->priority = $priority;
return $this;
}
/**
* Get priority
*
* @return int|null
*/
public function getPriority(): ?int
{
return $this->priority;
}
/**
* Set time to live
*
* @param int|null $timeToLive Time to live in milliseconds
* @return \Interop\Queue\Producer
*/
public function setTimeToLive(?int $timeToLive = null): Producer
{
$this->timeToLive = $timeToLive;
return $this;
}
/**
* Get time to live
*
* @return int|null
*/
public function getTimeToLive(): ?int
{
return $this->timeToLive;
}
}