/** * @test */ public function it_can_get_and_set() { $props = new MessageProperties(['foo' => 'bar']); $message = new Message('test'); $message->setBody('test2'); $message->setRoutingKey('route2'); $message->setProperties($props); $this->assertEquals('test2', $message->getBody()); $this->assertEquals('route2', $message->getRoutingKey()); $this->assertSame($props, $message->getProperties()); }
/** * @inheritdoc */ public function publish(Message $message, \DateTime $date = null, $flags = ExchangeInterface::NOPARAM) { if ($date instanceof \DateTime) { $delay = $date->getTimestamp() - time(); if ($delay < 0) { throw new \OutOFBoundsException('You cannot publish a message in the past'); } // set delay in milliseconds $message->setHeader(MessageProperties::KEY_DELAY, $delay * 1000); } $body = $message->getBody(); $route = $message->getRoutingKey(); $props = $message->getProperties()->toArray(); return $this->exchange->publish($body, $route, $flags, $props); }