Is it possible to turn off deserialization in Akka Projection?

I have a very simple use case of Akka Projection.
I use Avro for event serialization, and only need to move certain types of events to Kafka, in the same serialized format. There is no need to go through the deserialize-serialize cycle since Kafka can ingest serialized Avro data.

I can’t find how to bypass deserialization from the documentation of Akka Projection. Is it possible?
It would be great if I can use Akka Projection for it. Otherwise, I would have to write my own streaming job.

it doesn’t seem possible with the Cassandra plugin, because its Serialized and RawEvent are internal. I will create an issue on GitHub.

I would use a custom Serializer that keeps the actual payload as bytes, and deserializes that with the real Serializer on demand (lazy).

1 Like

that’s a good idea. so I can have

case class RawEvent(bytes: Array[Byte], manifest: String)

def fromBinary(bytes: Array[Byte], manifest: String): RawEvent = RawEvent(bytes, manifest)

How can I override the serializer binding in Akka Projection? Suppose I run Akka Persistence and Projection in the same application.

I hope Akka allows me to use a different serializer to deserialize the value serialized by the original sseriialzier. They will definitely have different serializer ids.

If I understand it correctly, I need to override the serializerId-serializer map, pointing all existing serializerIds to my dummy serializer.

It is not clear where to do that.

You should be able to find how to register a custom serializer in Serialization • Akka Documentation and Serialization • Akka Documentation

Note that you will not be able to selectively use the RawEvent only for the deserialization in the projections, but you would also use it from the EventSourcedBehavior. That might not be so nice, but you can hide that with an EventAdapter Event Sourcing • Akka Documentation

OK. I don’t want to change the existing serializers. I think I’m going to run the projection job as a separated app with its own config fire where I create instances of the dummy serialize but with Ids copied from the real serializers so that the events can be read as bytes.