JSON serialization for JDBC channel message store #9309
Replies: 2 comments 6 replies
-
|
Right. You made it so complex because you have to have that extra column for the payload type. So, the type info is stored together with data. You suggestion about documenting this might make sense, but let's if solution having both type and data in the same JSON is more appropriate! |
Beta Was this translation helpful? Give feedback.
-
|
I just tried it like this: The resulting JSON did not contain class information: I then tried serializing the whole message instead of only the payload: The JSON then looks like this: Now there is class information, but I don't know if it should be the intention to store the whole message and not just the payload? In both cases, there is an error message due to the So should the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
According to the documentation, you can use JSON as the serialization format for your JDBC channel message store by overriding the
ChannelMessageStorePreparedStatementSetter. However, I found it was not that easy. If you only do that, theMessageRowMapperthrows an exception that it cannot read what was written.These are all the things I had to do to make it work:
JdbcChannelMessageStore:ChannelMessageStorePreparedStatementSetterthat writes 2 colums: one with the type of the payload, and one with the serialized JSON of the payload.MessageRowMapper. Unfortunately, the setter atJdbcChannelMessageStoreonly accepts theMessageRowMapperclass, not theRowMapperinterface, but overriden themapRowis luckily possible.I also updated my Flyway script that creates the tables to add the
MESSAGE_PAYLOAD_TYPEcolumn:I wonder if this is the good approach to have (readable) JSON in the database instead of (unreadable) Java serialization in there? If so, maybe the documentation should be updated to provide a complete solution?
Beta Was this translation helpful? Give feedback.
All reactions