question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ListenerContainerWithDlqAndRetryCustomizer template points to localhost:9092

See original GitHub issue

Hi,

I am using following dependencies

spring-cloud-stream: 3.21
spring-cloud-stream-binder-kafka: 3.21
spring-kafka: 2.8.2

To forward deserialization errors to DLQ, I added the following bean:

	@Bean
	ListenerContainerWithDlqAndRetryCustomizer cust(KafkaTemplate<?, ?> template) {
		return new ListenerContainerWithDlqAndRetryCustomizer() {
			@Override
			public void configure(AbstractMessageListenerContainer<?, ?> container, String destinationName,
					String group,
					BiFunction<ConsumerRecord<?, ?>, Exception, org.apache.kafka.common.TopicPartition> dlqDestinationResolver,
					BackOff backOff) {
				ConsumerRecordRecoverer dlpr = new DeadLetterPublishingRecoverer(template, dlqDestinationResolver);
				container.setCommonErrorHandler(new DefaultErrorHandler(dlpr, backOff==null? new FixedBackOff(0L, 1L):backOff));
			}
                        ......
		};
	}

I have the following configuration in application.yml

spring.cloud:
    schemaRegistryClient:
      endpoint: .....
    stream:
      default:
        consumer:
          maxAttempts: 1
      function:
        definition: myDataConsumer
      bindings:        
        myDataConsumer-in-0:
          destination: input-topic
          ....
        myDataConsumer-output:
          destination: output-topic
          ...
      kafka:
        default:
          consumer:
            useNativeDecoding: true
            enableDlq: true
            dlqName: dlq-topic
        bindings:
          myDataConsumer-in-0:
            consumer:
                ...
        binder:
          brokers: "broker1Url,broker2Url"
          producer-properties:
               ...

When the application runs and if there are Deserialization errors, it tries to produce to non-existent localhost:9092 instead of the brokers in the config. What am I missing?

Thanks in advance

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sidsamantcommented, Apr 8, 2022
1reaction
garyrussellcommented, Mar 29, 2022

You are wiring in Boot’s auto-configured KafkaTemplate. Boot knows nothing about binders or binder configuration; it uses the normal Boot spring.kafka.... properties when configuring that template.

https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html#application-properties.integration.spring.kafka.bootstrap-servers

Read more comments on GitHub >

github_iconTop Results From Across the Web

ListenerContainerWithDlqAndRe...
ListenerContainerWithDlqAndRetryCustomizer template points to localhost :9092 spring-cloud/spring-cloud-stream-binder-kafka#1208.
Read more >
Spring Cloud Stream Kafka Binder Reference Guide
template ) { return new ListenerContainerWithDlqAndRetryCustomizer() { @Override ... expects that you are running the broker at the default localhost:9092 .
Read more >
Not able to create custom RetryTemplate using ...
I am using spring cloud stream with multiple binders . I tried to create custom RetryTemplate using @StreamRetryTemplate . Bean of custom ...
Read more >
spring-cloud/spring-cloud-stream-binder-kafka - Issues Antenna
ListenerContainerWithDlqAndRetryCustomizer template points to localhost :9092. 000. Hi, I am using following dependencies ...
Read more >
spring-cloud-stream-binder-kafka - bytemeta
ListenerContainerWithDlqAndRetryCustomizer template points to localhost :9092. wouterTj. wouterTj CLOSED · Updated 8 months ago ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found