We're using a hexagonal architecture in one of our microservice. Spring Boot is the framework implementing the service.
For a use case, we need to update a database table (relational) and send a message to a Kafka topic. Quite usual. We don't want to use any CDC or Outbox Pattern, but we want to rely on the transactional manager of Spring.
However, we need some clarification about how to implement this scenario. We don't want to have any dependency on the framework in the application layer (service/use case). How can we implement transactionality? Should we use the @Transactional
annotation on the controller? Should we have a single output port, for example, saveAndPublish
(I don't like this solution), and put the transaction management in the implementing adapter?
I know that every use case should be transactional by design.