/** * @param EventMessageInterface $eventMessage * @return AmqpMessage */ public function createAmqpMessage(EventMessageInterface $eventMessage) { $writer = new EventMessageWriter($this->serializer); $body = $writer->writeEventMessage($eventMessage); $routingKey = $this->routingKeyResolver->resolveRoutingKey($eventMessage); if ($this->durable) { return new AmqpMessage($body, $routingKey, array('delivery_mode' => 2), false, false); } return new AmqpMessage($body, $routingKey); }
public function testStreamDomainEventMessage() { $serializer = new JMSSerializer(); $writer = new EventMessageWriter($serializer); $payload = new StreamPayload("string", 10, 15.5); $message = new GenericDomainEventMessage(Uuid::uuid1(), 1, $payload, new MetaData(array("metaKey" => "MetaValue"))); $data = $writer->writeEventMessage($message); $reader = new EventMessageReader($serializer); $serializedMessage = $reader->readEventMessage($data); $this->assertTrue($serializedMessage instanceof DomainEventMessageInterface); $this->assertEquals($message->getIdentifier(), $serializedMessage->getIdentifier()); $this->assertEquals($message->getPayloadType(), $serializedMessage->getPayloadType()); $this->assertEquals($message->getTimestamp(), $serializedMessage->getTimestamp()); $this->assertEquals($message->getMetaData(), $serializedMessage->getMetaData()); $this->assertEquals($message->getPayload(), $serializedMessage->getPayload()); $this->assertEquals($message->getAggregateIdentifier(), $serializedMessage->getAggregateIdentifier()); $this->assertEquals($message->getScn(), $serializedMessage->getScn()); }