Does it make sense for the "serializedsaga" column to always be a blob or can we use JSONB?

I’m experimenting with serializing the sagaentry table to have its serializedSaga field be of type jsonb (using postgres).

All three Axon Framework serializers are setup to use Jackson but currently I get an error:

ERROR: column "serializedsaga" is of type jsonb but expression is of type bytea

Just before I try to solve this I wanted to know: does it even make sense to have the Saga be serialized to JSON from the perspective of the framework?

Or should it just remain as a blob in the DB?

And if it does make sense: how would this type be configured?

I get the JdbcTokenStore working with JSONB by using the the builder method contentType.
Similarly, I get the JdbcEventStorageEngine working with JSONB by using the builder dataType method.

But the JdbcSagaStore does not have such a method on the builder. That’s why I ask the question - does the framework just want it stored as a blob and not JSONB for any particular reason?

Who are we, to say if it makes sense, @vab2048? :slight_smile:
Honestly, I can imagine there’s value in seeing the contents of the Saga right there in the database.

But, for that, it doesn’t necessarily have to be JSONB, of course.
The default bytea format can just as well be adjusted to its string representation.
And this representation would turn out to be XML or JSON anyhow, depending on the Serializer you use.

Anyhow, if you feel there’s benefit in having it as JSONB in your application, you should be free to do so.
The fact the SagaStore doesn’t easily provide this, is simply because it’s not implemented yet.
So if you were to go down that path, you will have to do some customization on your end.

I hope this clarifies my stance on this, @vab2048!

Thanks @Steven_van_Beelen for clarifying.

I think I will make an issue for it on the tracker just so we can track any progress or if someone else is willing to contribute. I wish I had the time to do it myself… but alas not right now.

Edit: issue made here: Enhance `JdbcSagaStore` with ability to specify the content type for the serialized saga. · Issue #2214 · AxonFramework/AxonFramework · GitHub

1 Like