Skip to content

Binding name is null for commaSeparated destination #2380

Description

@skpandey91

I have below exception while starting an application with spring cloud enabled. (Spring cloud-3.0.1 and sping boot 2.4.6)

":"ERROR","logger":"org.springframework.cloud.stream.binding.BindingService","applicationName":"","message":"Failed to create consumer binding; retrying in 30 seconds","exception":"\norg.springframework.cloud.stream.binder.BinderException: Exception thrown while starting consumer: \n\tat org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:462)\n\tat org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:91)\n\tat org.springframework.cloud.stream.binder.AbstractBinder.bindConsumer(AbstractBinder.java:143)\n\tat org.springframework.cloud.stream.binding.BindingService.lambda$rescheduleConsumerBinding$1(BindingService.java:202)\n\tat org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)\n\tat java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)\n\tat java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)\n\tat java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat java.base/java.lang.Thread.run(Thread.java:829)\nCaused by: java.lang.IllegalArgumentException: 'bindingName' cannot be null\n\tat org.springframework.util.Assert.notNull(Assert.java:201)\n\tat org.springframework.cloud.stream.binder.kafka.KafkaMessageChannelBinder.setupRebalanceListener(KafkaMessageChannelBinder.java:821)\n\tat org.springframework.cloud.stream.binder.kafka.KafkaMessageChannelBinder.createConsumerEndpoint(KafkaMessageChannelBinder.java:663)\n\tat org.springframework.cloud.stream.binder.kafka.KafkaMessageChannelBinder.createConsumerEndpoint(KafkaMessageChannelBinder.java:158)\n\tat org.springframework.cloud.stream.binder.AbstractMessageChannelBinder.doBindConsumer(AbstractMessageChannelBinder.java:408)\n\t... 10 common frames omitted\n\n"}

This happening in case :

  1. I have comma separated destinations like below.
    MyChannel: destination: Topic1,Topic2 group: shopping-cart-golden-ms contentType: application/json partitionCount: 1

  2. I have a bean implementing KafkaBindingRebalanceListener in the application.

This is happening because below code in KafkaMessageChannelBinder.setupRebalanceListener is removing the binding name after the first iteration from binding-targets. Then next topic in the next iteration from the commaseparated list finds binding null in the mentioned method.
public void setupRebalanceListener(final ExtendedConsumerProperties<KafkaConsumerProperties> extendedConsumerProperties, final ContainerProperties containerProperties) { Assert.isTrue(!((KafkaConsumerProperties)extendedConsumerProperties.getExtension()).isResetOffsets(), "'resetOffsets' cannot be set when a KafkaBindingRebalanceListener is provided"); final String bindingName = (String)bindingNameHolder.get(); bindingNameHolder.remove();

 Please suggest some solution for this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions