$envelopeCustomRoutingKey =
new Envelope($customRoutingKeyMessage,
[ new DelayStamp(1000
),
new AmqpStamp('my_custom_routing_key'
),
]);
$sender->
send($envelopeCustomRoutingKey);
// wait for next message (but max at 3 seconds)
$startTime =
microtime(true
);
$envelopes =
$this->
receiveEnvelopes($receiver, 3
);
// duration should be about 1 second
$this->
assertApproximateDuration($startTime, 1
);
// this should be the custom routing key message first
$this->
assertCount(1,
$envelopes);
/* @var Envelope $envelope */
$receiver->
ack($envelopes[0
]);
$this->
assertEquals($customRoutingKeyMessage,
$envelopes[0
]->
getMessage());
// wait for final message (but max at 3 seconds)
$envelopes =
$this->
receiveEnvelopes($receiver, 3
);
// duration should be about 2 seconds
$this->
assertApproximateDuration($startTime, 2
);