Best practices how to deal with binary data (like PDF documents) in events

Hi everyone,

currently we use a JPA based Event Store and use XStream to serialize the events. We consider moving to the JsonSerializer, but with both solutions we wonder how to store binary data like PDF documents.

Putting them as binary data into xml or Jain feels cumbersome.

Are there any best practices how to deal with this issue?

Thanks!

Kind regards
Oliver

Hi Oliver,

The best practice when dealing with files is to put a reference to the file in the event instead of the representation of it. So if the file is stored in S3 for instance, you can add the location of the file into your event. I hope this helps,

Best!

Yvonne Ceelie

Hi Yvonne,

thanks for answering. I do not want to use a cloud service like S3 as it’s not ensured that the users of the application have internet access. Moreover, it’s hard to store the event and the binary data in a guarenteed consistent way.

I thought about storing binary data in a dedicated database table and referencing those entries from the event. Anyway, having this I have to provide an API to external modules in order to access the binary data as those modules are not allowed to access the module’s internal database.

Anyway, these solutions feel quite unhandy and I hope to find a solution which feels a bit more “Axon native”.

Kind regards
Oliver