6
6
use Interop \Amqp \AmqpProducer as InteropAmqpProducer ;
7
7
use Interop \Amqp \AmqpQueue as InteropAmqpQueue ;
8
8
use Interop \Amqp \AmqpTopic as InteropAmqpTopic ;
9
+ use Interop \Queue \DeliveryDelayNotSupportedException ;
9
10
use Interop \Queue \InvalidDestinationException ;
10
11
use Interop \Queue \InvalidMessageException ;
11
12
use Interop \Queue \PsrDestination ;
17
18
18
19
class AmqpProducer implements InteropAmqpProducer
19
20
{
21
+ /**
22
+ * @var int|null
23
+ */
24
+ private $ priority ;
25
+
26
+ /**
27
+ * @var int|float|null
28
+ */
29
+ private $ timeToLive ;
30
+
20
31
/**
21
32
* @var AMQPChannel
22
33
*/
@@ -43,6 +54,14 @@ public function send(PsrDestination $destination, PsrMessage $message)
43
54
44
55
InvalidMessageException::assertMessageInstanceOf ($ message , InteropAmqpMessage::class);
45
56
57
+ if (null !== $ this ->priority && null === $ message ->getPriority ()) {
58
+ $ message ->setPriority ($ this ->priority );
59
+ }
60
+
61
+ if (null !== $ this ->timeToLive && null === $ message ->getExpiration ()) {
62
+ $ message ->setExpiration ($ this ->timeToLive );
63
+ }
64
+
46
65
$ amqpProperties = $ message ->getHeaders ();
47
66
48
67
if ($ appProperties = $ message ->getProperties ()) {
@@ -69,4 +88,52 @@ public function send(PsrDestination $destination, PsrMessage $message)
69
88
);
70
89
}
71
90
}
91
+
92
+ /**
93
+ * {@inheritdoc}
94
+ */
95
+ public function setDeliveryDelay ($ deliveryDelay )
96
+ {
97
+ throw DeliveryDelayNotSupportedException::providerDoestNotSupportIt ();
98
+ }
99
+
100
+ /**
101
+ * {@inheritdoc}
102
+ */
103
+ public function getDeliveryDelay ()
104
+ {
105
+ return null ;
106
+ }
107
+
108
+ /**
109
+ * {@inheritdoc}
110
+ */
111
+ public function setPriority ($ priority )
112
+ {
113
+ $ this ->priority = $ priority ;
114
+ }
115
+
116
+ /**
117
+ * {@inheritdoc}
118
+ */
119
+ public function getPriority ()
120
+ {
121
+ return $ this ->priority ;
122
+ }
123
+
124
+ /**
125
+ * {@inheritdoc}
126
+ */
127
+ public function setTimeToLive ($ timeToLive )
128
+ {
129
+ $ this ->timeToLive = $ timeToLive ;
130
+ }
131
+
132
+ /**
133
+ * {@inheritdoc}
134
+ */
135
+ public function getTimeToLive ()
136
+ {
137
+ return $ this ->timeToLive ;
138
+ }
72
139
}
0 commit comments