66use Interop \Amqp \AmqpProducer as InteropAmqpProducer ;
77use Interop \Amqp \AmqpQueue as InteropAmqpQueue ;
88use Interop \Amqp \AmqpTopic as InteropAmqpTopic ;
9+ use Interop \Queue \DeliveryDelayNotSupportedException ;
910use Interop \Queue \InvalidDestinationException ;
1011use Interop \Queue \InvalidMessageException ;
1112use Interop \Queue \PsrDestination ;
1718
1819class AmqpProducer implements InteropAmqpProducer
1920{
21+ /**
22+ * @var int|null
23+ */
24+ private $ priority ;
25+
26+ /**
27+ * @var int|float|null
28+ */
29+ private $ timeToLive ;
30+
2031 /**
2132 * @var AMQPChannel
2233 */
@@ -43,6 +54,14 @@ public function send(PsrDestination $destination, PsrMessage $message)
4354
4455 InvalidMessageException ::assertMessageInstanceOf ($ message , InteropAmqpMessage::class);
4556
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+
4665 $ amqpProperties = $ message ->getHeaders ();
4766
4867 if ($ appProperties = $ message ->getProperties ()) {
@@ -69,4 +88,52 @@ public function send(PsrDestination $destination, PsrMessage $message)
6988 );
7089 }
7190 }
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+ }
72139}
0 commit comments