Serializes an object. It must subclass :class:`FranzEvent`.

        Parameters
        ----------
        message : FranzEvent
            The object to be serialized.

        Returns
        -------
        bytes

def serialize_message(message):
        """
        Serializes an object. It must subclass :class:`FranzEvent`.

        Parameters
        ----------
        message : FranzEvent
            The object to be serialized.

        Returns
        -------
        bytes
        """
        try:
            return bson.dumps(message.serialize())
        except bson.UnknownSerializerError:
            raise SerializationError(
                "Unable to serialize message: {}.".format(message)
            )