org.springframework.messaging.MessagingException: Consuming from Kafka failed

Spring JIRA | Jaroslaw Palka | 3 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    I have found that when you define two consumer contexts and two inbound channel adapters, like this: {code:xml} <kafka:consumer-context id="response-consumer-context" zookeeper-connect="zookeeper-connect"> <kafka:consumer-configurations> <kafka:consumer-configuration group-id="response-gateway-group" key-decoder="string-decoder" value-decoder="string-decoder"> <kafka:topic streams="1" id="response" /> </kafka:consumer-configuration> </kafka:consumer-configurations> </kafka:consumer-context> <kafka:consumer-context id="error-consumer-context" zookeeper-connect="zookeeper-connect"> <kafka:consumer-configurations> <kafka:consumer-configuration group-id="error-gateway-group" key-decoder="string-decoder" value-decoder="string-decoder"> <kafka:topic streams="1" id="error" /> </kafka:consumer-configuration> </kafka:consumer-configurations> </kafka:consumer-context> <kafka:inbound-channel-adapter id="responseKafkaDestination" kafka-consumer-context-ref="response-consumer-context"> <int:poller fixed-delay="10" /> </kafka:inbound-channel-adapter> <kafka:inbound-channel-adapter id="errorKafkaDestination" kafka-consumer-context-ref="error-consumer-context"> <int:poller fixed-delay="10" /> </kafka:inbound-channel-adapter> {code} you get following error: {noformat} [task-scheduler-6] ERROR org.springframework.integration.handler.LoggingHandler - org.springframework.messaging.MessagingException: Consuming from Kafka failed at org.springframework.integration.kafka.support.ConsumerConfiguration.executeTasks(ConsumerConfiguration.java:110) at org.springframework.integration.kafka.support.ConsumerConfiguration.receive(ConsumerConfiguration.java:86) at org.springframework.integration.kafka.support.KafkaConsumerContext.receive(KafkaConsumerContext.java:56) at org.springframework.integration.kafka.inbound.KafkaHighLevelConsumerMessageSource.receive(KafkaHighLevelConsumerMessageSource.java:41) at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:124) at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:190) at org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:55) at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:149) at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:146) at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:284) at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52) at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50) at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:49) at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:278) at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Iterator is in failed state at java.util.concurrent.FutureTask$Sync.innerGet(Unknown Source) at java.util.concurrent.FutureTask.get(Unknown Source) at org.springframework.integration.kafka.support.ConsumerConfiguration.executeTasks(ConsumerConfiguration.java:97) ... 23 more Caused by: java.lang.IllegalStateException: Iterator is in failed state at kafka.utils.IteratorTemplate.hasNext(IteratorTemplate.scala:54) at kafka.utils.IteratorTemplate.next(IteratorTemplate.scala:38) at kafka.consumer.ConsumerIterator.next(ConsumerIterator.scala:46) at org.springframework.integration.kafka.support.ConsumerConfiguration$1.call(ConsumerConfiguration.java:67) at org.springframework.integration.kafka.support.ConsumerConfiguration$1.call(ConsumerConfiguration.java:61) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) ... 3 more {noformat}

    Spring JIRA | 3 years ago | Jaroslaw Palka
    org.springframework.messaging.MessagingException: Consuming from Kafka failed
  2. 0

    I have found that when you define two consumer contexts and two inbound channel adapters, like this: {code:xml} <kafka:consumer-context id="response-consumer-context" zookeeper-connect="zookeeper-connect"> <kafka:consumer-configurations> <kafka:consumer-configuration group-id="response-gateway-group" key-decoder="string-decoder" value-decoder="string-decoder"> <kafka:topic streams="1" id="response" /> </kafka:consumer-configuration> </kafka:consumer-configurations> </kafka:consumer-context> <kafka:consumer-context id="error-consumer-context" zookeeper-connect="zookeeper-connect"> <kafka:consumer-configurations> <kafka:consumer-configuration group-id="error-gateway-group" key-decoder="string-decoder" value-decoder="string-decoder"> <kafka:topic streams="1" id="error" /> </kafka:consumer-configuration> </kafka:consumer-configurations> </kafka:consumer-context> <kafka:inbound-channel-adapter id="responseKafkaDestination" kafka-consumer-context-ref="response-consumer-context"> <int:poller fixed-delay="10" /> </kafka:inbound-channel-adapter> <kafka:inbound-channel-adapter id="errorKafkaDestination" kafka-consumer-context-ref="error-consumer-context"> <int:poller fixed-delay="10" /> </kafka:inbound-channel-adapter> {code} you get following error: {noformat} [task-scheduler-6] ERROR org.springframework.integration.handler.LoggingHandler - org.springframework.messaging.MessagingException: Consuming from Kafka failed at org.springframework.integration.kafka.support.ConsumerConfiguration.executeTasks(ConsumerConfiguration.java:110) at org.springframework.integration.kafka.support.ConsumerConfiguration.receive(ConsumerConfiguration.java:86) at org.springframework.integration.kafka.support.KafkaConsumerContext.receive(KafkaConsumerContext.java:56) at org.springframework.integration.kafka.inbound.KafkaHighLevelConsumerMessageSource.receive(KafkaHighLevelConsumerMessageSource.java:41) at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:124) at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:190) at org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:55) at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:149) at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:146) at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:284) at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52) at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50) at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:49) at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:278) at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Iterator is in failed state at java.util.concurrent.FutureTask$Sync.innerGet(Unknown Source) at java.util.concurrent.FutureTask.get(Unknown Source) at org.springframework.integration.kafka.support.ConsumerConfiguration.executeTasks(ConsumerConfiguration.java:97) ... 23 more Caused by: java.lang.IllegalStateException: Iterator is in failed state at kafka.utils.IteratorTemplate.hasNext(IteratorTemplate.scala:54) at kafka.utils.IteratorTemplate.next(IteratorTemplate.scala:38) at kafka.consumer.ConsumerIterator.next(ConsumerIterator.scala:46) at org.springframework.integration.kafka.support.ConsumerConfiguration$1.call(ConsumerConfiguration.java:67) at org.springframework.integration.kafka.support.ConsumerConfiguration$1.call(ConsumerConfiguration.java:61) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) ... 3 more {noformat}

    Spring JIRA | 3 years ago | Jaroslaw Palka
    org.springframework.messaging.MessagingException: Consuming from Kafka failed
  3. 0

    Consuming from Kafka failed Iterator is in failed state

    Stack Overflow | 2 years ago | Amit
    java.lang.IllegalStateException: Iterator is in failed state
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    How can I cope with "IllegalStateException: BeanFactory not initialized or already closed"?

    Stack Overflow | 6 years ago | user569825
    java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
  6. 0

    issues in spring petclinic applicaiton

    Stack Overflow | 4 years ago | user2216702
    java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - c all 'refresh' before multicasting events via the context: Root WebApplicationCon text: startup date [Wed Mar 27 11:31:56 CDT 2013]; root of context hierarchy at org.springframework.context.support.AbstractApplic ationContext.getApp licationEventMulticaster(AbstractApplicationContex t.java:347) [spring-context-3. 2.2.RELEASE.jar:3.2.2.RELEASE] at org.springframework.context.support.AbstractApplic ationContext.publis hEvent(AbstractApplicationContext.java:334) [spring-context-3.2.2.RELEASE.jar:3. 2.2.RELEASE] at org.springframework.context.support.AbstractApplic ationContext.doClos e(AbstractApplicationContext.java:1049) [spring-context-3.2.2.RELEASE.jar:3.2.2. RELEASE] at org.springframework.context.support.AbstractApplic ationContext.close( AbstractApplicationContext.java:1010) [spring-context-3.2.2.RELEASE.jar:3.2.2.RE LEASE] at org.springframework.web.context.ContextLoader.clos eWebApplicationCont ext(ContextLoader.java:558) [spring-web-3.2.2.RELEASE.jar:3.2.2.RELEASE] at org.springframework.web.context.ContextLoaderListe ner.contextDestroye d(ContextLoaderListener.java:143) [spring-web-3.2.2.RELEASE.jar:3.2.2.RELEASE] at org.apache.catalina.core.StandardContext.listenerS top(StandardContext .java:4831) [tomcat-embed-core-7.0.30.jar:7.0.30] at org.apache.catalina.core.StandardContext.stopInter nal(StandardContext .java:5478) [tomcat-embed-core-7.0.30.jar:7.0.30] at org.apache.catalina.util.LifecycleBase.stop(Lifecy cleBase.java:232) [ tomcat-embed-core-7.0.30.jar:7.0.30] at org.apache.catalina.util.LifecycleBase.start(Lifec ycleBase.java:160) [tomcat-embed-core-7.0.30.jar:7.0.30] at org.apache.catalina.core.ContainerBase$StartChild. call(ContainerBase. java:1559) [tomcat-embed-core-7.0.30.jar:7.0.30] at org.apache.catalina.core.ContainerBase$StartChild. call(ContainerBase. java:1549) [tomcat-embed-core-7.0.30.jar:7.0.30] at java.util.concurrent.FutureTask$Sync.innerRun(Futu reTask.java:303) [n a:1.6.0_20] at java.util.concurrent.FutureTask.run(FutureTask.jav a:138) [na:1.6.0_20 ] at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExec utor.java:886) [na:1.6.0_20] at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor .java:908) [na:1.6.0_20]

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalStateException

      Iterator is in failed state

      at kafka.utils.IteratorTemplate.hasNext()
    2. Apache Kafka
      ConsumerIterator.next
      1. kafka.utils.IteratorTemplate.hasNext(IteratorTemplate.scala:54)
      2. kafka.utils.IteratorTemplate.next(IteratorTemplate.scala:38)
      3. kafka.consumer.ConsumerIterator.next(ConsumerIterator.scala:46)
      3 frames
    3. org.springframework.integration
      ConsumerConfiguration$1.call
      1. org.springframework.integration.kafka.support.ConsumerConfiguration$1.call(ConsumerConfiguration.java:67)
      2. org.springframework.integration.kafka.support.ConsumerConfiguration$1.call(ConsumerConfiguration.java:61)
      2 frames
    4. Java RT
      Thread.run
      1. java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
      2. java.util.concurrent.FutureTask.run(Unknown Source)
      3. java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
      4. java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      5. java.lang.Thread.run(Unknown Source)
      5 frames