GithubHelp home page GithubHelp logo

Comments (13)

garyrussell avatar garyrussell commented on May 19, 2024

There is no manipulation of the String value for the broker list; it is passed into Kafka as a property unchanged here. Perhaps you have some other version of your config with the comma on your classpath?

from spring-integration-kafka.

rssdev10 avatar rssdev10 commented on May 19, 2024

Thanks, and sorry, I'm not familiar with Spring Integration. I tried to use your examples and description from https://github.com/spring-projects/spring-integration-kafka. Like this

<int-kafka:message-driven-channel-adapter
            id="adapter"
            channel="output"
            connection-factory="connectionFactory"
            key-decoder="decoder"
            payload-decoder="decoder"
            offset-manager="offsetManager"
            max-fetch="100"
            topics="${kafka.test.topic}"/>

How to configure the broker list directly? https://github.com/rssdev10/flink-spring-integration/blob/master/drpc-client/src/main/resources/flink-integration-context.xml

BTW: what is the topics string format?

And regarding Kafka I nothing changed in they typical config.

from spring-integration-kafka.

artembilan avatar artembilan commented on May 19, 2024

Try to use BrokerAddressListConfiguration instead of ZookeeperConfiguration.
Also it is really isn't clear why your current solution fail with the strange resolution to the localhost,:9092.
The code to consider ( ZookeeperConfiguration):

    zkClient = new ZkClient(this.zookeeperServers, this.sessionTimeout, this.connectionTimeout,
                    ZKStringSerializer$.MODULE$);
            Seq<Broker> allBrokersInCluster = ZkUtils$.MODULE$.getAllBrokersInCluster(zkClient);
            FastList<Broker> brokers = FastList.newList(JavaConversions.asJavaCollection(allBrokersInCluster));
            return brokers.collect(brokerToBrokerAddressFunction);

and DefaultConnectionFactory:

String brokerAddressesAsString = ListIterate
                    .collect(this.configuration.getBrokerAddresses(), Functions.getToString()).makeString(",");

from spring-integration-kafka.

rssdev10 avatar rssdev10 commented on May 19, 2024

@artembilan thanks, BrokerAddressConfiguration works.

    <bean id="connectionFactory"
        class="org.springframework.integration.kafka.core.DefaultConnectionFactory">
        <!-- <constructor-arg ref="zookeeperConfiguration" />  -->
        <constructor-arg ref="brokerConfig" />
    </bean>

    <bean id="brokerConfig"
        class="org.springframework.integration.kafka.core.BrokerAddressListConfiguration">
        <constructor-arg value="#{T(org.springframework.integration.kafka.core.BrokerAddress).fromAddress('localhost:9092')}" />
    </bean>

But is it possible to configure one without such terrible SpEL?

from spring-integration-kafka.

artembilan avatar artembilan commented on May 19, 2024

Just make BrokerAddress as inner bean!

 <bean id="brokerConfig"
        class="org.springframework.integration.kafka.core.BrokerAddressListConfiguration">
        <constructor-arg>
             <bean class="org.springframework.integration.kafka.core.BrokerAddress" factory-method="fromAddress">
               <constructor-arg value="localhost:9092"/>
            </bean>
        </constructor-arg>
    </bean>

But SpEL should be shorter.
From other side it would be great to understand who breaks localhost:9092 to the localhost,:9092 for you in case of ZookeeperConfiguration...

Would you mind to debug your application with break points on the Spring Integration Kafka code, e.g. ZookeeperConfiguration.doGetBrokerAddresses() will be a good candidate?

from spring-integration-kafka.

rssdev10 avatar rssdev10 commented on May 19, 2024

dogetbrokeraddresses

from spring-integration-kafka.

artembilan avatar artembilan commented on May 19, 2024

M-m-m. Any comments, please. I'm not familiar with Eclipse:
The screenshot from IDEA:
kafkabrokers

from spring-integration-kafka.

artembilan avatar artembilan commented on May 19, 2024

According to your screen it really shows that Zookeeper returns localhost, as a host for your broker.
Not sure where that is broken, but right now it is out of our hands.
We can't control it on Spring Integration Kafka side.

from spring-integration-kafka.

rssdev10 avatar rssdev10 commented on May 19, 2024

Eclipse is not so hard :) . Left upper part contains a current state of variables and "localhost," is shown.

I guess the problem is somewhere in ZkUtils / getBrokerInfo(zkClient, _).

  def getAllBrokersInCluster(zkClient: ZkClient): Seq[Broker] = {
    val brokerIds = ZkUtils.getChildrenParentMayNotExist(zkClient, ZkUtils.BrokerIdsPath).sorted
    brokerIds.map(_.toInt).map(getBrokerInfo(zkClient, _)).filter(_.isDefined).map(_.get)
  }

Kafka for me is new product too. I can't comment anything.

from spring-integration-kafka.

rssdev10 avatar rssdev10 commented on May 19, 2024

I found the reason. /etc/hosts contained a comma as a separator....

127.0.0.1       localhost, linux-...

When I fixed it and restarted Kafka the application was started correctly.
Thanks for the advises. And please add error info in doGetBrokerAddresses() to avoid anonymous java.lang.NullPointerException.

from spring-integration-kafka.

artembilan avatar artembilan commented on May 19, 2024

Thank you for the final solution!

Yes, we definitely should fix it.
Doing that now...

from spring-integration-kafka.

artembilan avatar artembilan commented on May 19, 2024

Well, I'm not sure that we can do here so much:

java.lang.NullPointerException
    at scala.Predef$.Integer2int(Predef.scala:392)
    at kafka.client.ClientUtils$$anonfun$parseBrokerList$1.apply(ClientUtils.scala:103)
    at kafka.client.ClientUtils$$anonfun$parseBrokerList$1.apply(ClientUtils.scala:102)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
    at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
    at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
    at scala.collection.AbstractTraversable.map(Traversable.scala:105)
    at kafka.client.ClientUtils$.parseBrokerList(ClientUtils.scala:102)
    at org.springframework.integration.kafka.core.DefaultConnectionFactory.refreshMetadata(DefaultConnectionFactory.java:175)

Looks like Kafka should take care about the null for the port.

Anyway, I'll throw some IllegalState for the ClientUtils$.parseBrokerList with the appropriate brokerAddressesAsString to see the issue in the logs.

from spring-integration-kafka.

artembilan avatar artembilan commented on May 19, 2024

See #98

from spring-integration-kafka.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.