Hello,
I implemented this pattern through Atlas Mongo DB Source Connector with Kafka. Because the Mongo-Kafka Connector on Confluent Cloud does not support mapping specific documents to different topics, I ended up creating a collection for each event that I have.
So, collection “event1” has a corresponding topic “event1” in Kafka. I use the Change Stream functionality to relay information to the topics. Once a new document is inserted into “event1” collection (through a transaction, hence the Outbox Pattern), the same document is relay to the “event1” Kafka topic, thanks to the Change Stream. This ensures an at-least-once delivery of messages.
I have to say, this approach works when you have a limited set of events. Managing them is also not that easy. But at least this is a workaround.