Skip to content
Advertisement

How to deserialize BigDecimal value received from kafka broker through debezium CDC mechanism?

I have a couple of microservices developed using spring boot and each has its own Postgres database. These microservices exchange data with a CDC mechanism provided by debezium platform through kafka broker and kafka connect. I have a microservice A that stores some entities with a BigDecimal attribute. Another microservice B depends on the data stored by A so it gets it through kafka topics as a message like the following:

JavaScript

The coefficient attribute is a BigDecimal and it is stored in microservice A database as a BigDecimal (4.00).

How come 4.00 is converted to “AZA=”? Is “AZA=” some encoding format to preserve the BigDecimal precision? How to go from “AZA=” to 4.0 again?

To note that jackson fails to deserialize the string value of “AZA=” to a BigDecimal value with the exception:

JavaScript

Any hint or any help will be appreciated! thanks!

Advertisement

Answer

this is solution for Java – https://debezium.io/documentation/faq/#how_to_retrieve_decimal_field_from_binary_representation

Also please check decimal.handling.mode option for other ways how BigDecimal can be encoded into the message.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement