protected function insertEvent(StreamName $streamName, DomainEvent $e)
    {
        $eventData = array(
            'event_id' => $e->uuid()->toString(),
            'version' => $e->version(),
            'event_name' => $e->messageName(),
            'event_class' => get_class($e),
            'payload' => Serializer::serialize($e->payload(), $this->serializerAdapter),
            'created_at' => $e->createdAt()->format(\DateTime::ISO8601)
        );

        foreach ($e->metadata() as $key => $value) {
            $eventData[$key] = (string)$value;
        }

        $tableGateway = $this->getTablegateway($streamName);

        $tableGateway->insert($eventData);
    }