Last active
March 28, 2024 08:22
-
-
Save serdarmumcu/93214764602f0a90ce3d28bdb7e1efb7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
public class DataService { | |
@Autowired | |
private DatabaseRepository databaseRepository; | |
@Autowired | |
private KafkaTemplate<String, String> kafkaTemplate; | |
@Transactional | |
public void updateDataAndPublishEvent(String data) { | |
databaseRepository.save(new DataEntity(data)); // Database operation | |
kafkaTemplate.send("topicName", "Data updated event"); // Kafka event publishing | |
// The above operations are not atomically consistent, risking data inconsistency. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment