Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow filtering or sending different event to different topics in the publisher. #260

Closed
gklijs opened this issue Mar 23, 2022 · 0 comments · Fixed by #264
Closed

Allow filtering or sending different event to different topics in the publisher. #260

gklijs opened this issue Mar 23, 2022 · 0 comments · Fixed by #264

Comments

@gklijs
Copy link
Collaborator

gklijs commented Mar 23, 2022

Feature Description

In some cases we want to only send certain events via Kafka. Also a typical Kafka setup is using a different topic for each message type. It would be nice if this was configurable.

Current Behaviour

Currently there is just one topic to which all events are sent.

Wanted Behaviour

Add an optional mapping lambda, from EventMessage to Optional KafkaPublisher<String, byte[]>. By default this will send all events to the default "Axon.Events" topic, if a topic is used in the builder, it will use a lambda that always returns the set topic.
If the lambda returns an empty optional the event will be skipped. Note that by using the lamda on the EventMessage, it's both versatile, and we can skip the conversion step if the event doesn't need to be sent via Kafka.
Something like:

m -> {
   if (m.getPayloadType() instance of WantedEvent) {
    return Optional.of("wanted-events-topic");
  } else {
    return Optional.empty()
  }
}

Possible Workarounds

Skipping the extension, and doing it yourself, for example with Spring Cloud Streams, which needs a lot more code to setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants