spring-cloud / spring-cloud-stream-binder-kafka

Spring Cloud Stream binders for Apache Kafka and Kafka Streams
Apache License 2.0
331 stars 301 forks source link

multiple Flux suppliers don't work #1011

Closed benkeil closed 3 years ago

benkeil commented 3 years ago

I have a spring cloud stream kafka application with two suppliers. But it only works, if I comment one out (both are working if the other one is not there).

@Bean
public Supplier<Flux<Message<Product>>> productSupplier() {
    return () -> Flux.from(emitter -> {
        while (true) {
            try {
                emitter.onNext(createProductMessage());
                Thread.sleep(1000);
            } catch (Exception e) {
                // ignore
            }
        }
    });
}

and in another class

@Bean
public Supplier<Flux<Message<Channel>>> channelSupplier() {
    return () -> Flux.from(emitter -> {
        while (true) {
            try {
                emitter.onNext(createChannelMessage());
                Thread.sleep(1000);
            } catch (Exception e) {
                // ignore
            }
        }
    });
}

Edit

When I change both suppliers to work without Flux, everything works.

garyrussell commented 3 years ago

See the documentation.

When there is more than one binding, you must specify them using the spring.cloud.function.definition property (productSupplier;channelSupplier).

benkeil commented 3 years ago

When I change both suppliers to work without Flux, everything works.

It has nothing to do with a wrong configuration...

garyrussell commented 3 years ago

If you are still having problems, reopen this and provide a complete, minimal, example that exhibits the behavior you see.