0

First time using the custom router function which would act as a filter as mentioned in the docs here and I was wondering, who do I redirect the input to?

In the past I had only the consumer which is declared as follows:

@Bean
public Consumer<Message<MyClass<T>>> myFunction() {
    return ...;
}

Together with the properties set as:

spring:
  cloud:
    stream:
      bindings:
        myFunction-in-0: "input"
        input:
          destination: "my-kinesis"
          binder: kinesis
          group: "my-group"

But now, having a custom router declared, I'm confused if that is still the proper input as myFunction-in-0.

The custom router function returns the following FunctionRoutingResult:

            return new MessageRoutingCallback.FunctionRoutingResult(
                    myCondition ? "myFunction" : "devNull"
            );

Also, added the devNull sink for cases where the condition is not met.

    @Bean
    public Consumer<Message<MyClass<?>>> devNull() {
        return ...;
    }

EDIT: the error thrown is as follows:

Failed to bind properties under 'spring.cloud.stream.bindings.myfunction-in-0' to org.springframework.cloud.stream.config.BindingProperties:

    Reason: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [org.springframework.cloud.stream.config.BindingProperties]

Action:

Update your application's configuration

spring-cloud-stream version: 3.2.4

spring-boot-starter-parent version: 2.6.6

spring-cloud-dependencies version: 2021.0.3

Could it be the generics in the received message? Can it be automatically parsed into the POJO?

czr_RR
  • 541
  • 5
  • 16
  • What exactly is the signature of `public Consumer>> myFunction() `? I am really curious as to why is it thinking that it is converting String to BindingProperties. Best thing you can do is provide a small sample that reproduces the issue and push i to github somewhere so we can tale a look quickly – Oleg Zhurakousky Sep 02 '22 at 14:31
  • @OlegZhurakousky will do! In here https://github.com/spring-cloud/spring-cloud-stream/pulls? – czr_RR Sep 05 '22 at 07:27
  • @OlegZhurakousky just got it fixed by wrapping all `binder, destination, etc` properties right after the `functionRouter-in-0` config clause, instead of ref the `input` name. Probably not valid when using routing functions and only when having a single function? – czr_RR Sep 05 '22 at 08:37

0 Answers0