What’s the recommended approach, if any, to publish an event to a specified topic? This sounds counter-intuitive as Axon as “Location Transparent,” but we have a requirement to do so. Ideally, there’s a way to achieve this via Spring configuration with some custom beans, so that dispatching in an @Aggregate class will allow us to continue to use AggregateLifecycle.apply(). Any thoughts?
The Kafka axon extension does support different producer and consumer topics quite easily (see application properties).
As for best practice it depends on a lot of variables including: retention, and replication/redundancy factors. So that’s more from a Kafka perspective.
When handling non-domain events we try not to handle this kind of work through Axon since these events are usually not ones we want to store in the domain_event_entry table (disk space concerns).
One solution is to define a mapping of payload types to topics, and setting the message topic in your KafkaMessageConverter according to the type of the payload .
Hi Ryan, Michael,
When you’re utilizing the Axon Kafka Extension, the mechanism to dispatch events on Kafka topics is dealt with by the KafkaPublisher.
The KafkaPublisher will use the EventBus as the SubscribableMessageSource to receive events as they occur and it will populate them on a single topic.
It should be doable to simply introduce another KafkaPublisher for a different topic, especially in a Spring environment.
However you are currently not able to do this through the provided auto configuration, as this currently only expects a single topic.
Would be a nice feature to introduce by the way; I assume this will pop up on the backlog one day.
Hope this helps!