receiveEnvelopes example

// send a 2nd message with a shorter delay and custom routing key         $customRoutingKeyMessage = new DummyMessage('custom routing key');
        $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)
Home | Imprint | This part of the site doesn't use cookies.