Now, let's see how we can implement Spring declarative transaction management.
Our Messages App is so simple that it works fine without transaction management. For demonstration purpose, let's add another requirement to the /messages (POST) API. Let's say we want to have a report to show the statistics of hourly posted messages. We can calculate the statistics using an SQL query. Or we can update the statistics after saving a message and save it into a table that will hold this information in the database. Let's go with the second approach so that we can use declarative transaction management.