Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Dynamic routing by KafkaBinder #1164

Open
uladzislau-belykh opened this issue Nov 3, 2021 · 2 comments
Open

Dynamic routing by KafkaBinder #1164

uladzislau-belykh opened this issue Nov 3, 2021 · 2 comments

Comments

@uladzislau-belykh
Copy link

Hi,

I am trying to create a simple application that will consume records from one topic and route them to multiple topics. I have an expression that resolves the destination route. Also I use Ack and KafkaIntegrationHeaders.FLUSH for providing guarantees.

I've had the next tries:

  1. I've tried to use BinderAwareChannelResolver and to resolve each destination separately. The problem is that we can't make "flush" for all of them at the same time, because each of them has separate KafkaTemplate

  2. For the next try, I've found topicExpression in KafkaProducerMessageHandler. But for using it Kafka binder creates a useless topic(by name of destination) and the "autoCreateTopics" property doesn't work for it.
    Is it expected behavior?

Can you advise me on how to do my task in the best way?

@sobychacko
Copy link
Contributor

sobychacko commented Nov 3, 2021

BinderAwareChannelResolver is deprecated in favor of the following options.

  1. Use the spring.cloud.stream.sendto.destination property. More details here.
  2. For more granular control, a new StreamBridge API is provided. See more details here.

Try one of these options and see if that fits your use case.

@uladzislau-belykh
Copy link
Author

First of all, sorry, I mixed parts from different modules.

As I know all of them use the same workflow inside (create a new MessageHandler, ProducerFactory, and KafkaTemplate for each new destination).

In my case, I need to have the opportunity to call "flush" for all my destinations at the same time. Probably, it can be achieved by using the same ProducerFactory for all my destinations(as it works when transactionIdPrefix is set). Can it be done without using transactions?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants