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 ()) {
@@ -75,7 +94,7 @@ public function send(PsrDestination $destination, PsrMessage $message)
7594 */
7695 public function setDeliveryDelay ($ deliveryDelay )
7796 {
78- throw new \ LogicException ( ' Not implemented ' );
97+ throw new DeliveryDelayNotSupportedException ( ' The provider does not support delivery delay feature ' );
7998 }
8099
81100 /**
@@ -91,30 +110,30 @@ public function getDeliveryDelay()
91110 */
92111 public function setPriority ($ priority )
93112 {
94- throw new \ LogicException ( ' Not implemented ' ) ;
113+ $ this -> priority = $ priority ;
95114 }
96115
97116 /**
98117 * {@inheritdoc}
99118 */
100119 public function getPriority ()
101120 {
102- return null ;
121+ return $ this -> priority ;
103122 }
104123
105124 /**
106125 * {@inheritdoc}
107126 */
108127 public function setTimeToLive ($ timeToLive )
109128 {
110- throw new \ LogicException ( ' Not implemented ' ) ;
129+ $ this -> timeToLive = $ timeToLive ;
111130 }
112131
113132 /**
114133 * {@inheritdoc}
115134 */
116135 public function getTimeToLive ()
117136 {
118- return null ;
137+ return $ this -> timeToLive ;
119138 }
120139}
0 commit comments