Spring integration Kafka XML argument error

僤鯓⒐⒋嵵緔 提交于 2019-12-11 12:31:11

问题


The kafka and zookeeper works fine because I've tried the basic method for JAVA to produce or consume a message, so the problem here is that, I'm considering using Spring integration Kafka with my project and the XML file is like this:

<int:channel id="inputToKafka">
    <int:queue/>
</int:channel>
<int-kafka:outbound-channel-adapter id="kafkaOutboundChannelAdapter"
                                    kafka-producer-context-ref="kafkaProducerContext"
                                    auto-startup="false"
                                    channel="inputToKafka"
                                    order="3"
        >
    <int:poller fixed-delay="1000" time-unit="MILLISECONDS" receive-timeout="0" task-executor="taskExecutor"/>
</int-kafka:outbound-channel-adapter>
<task:executor id="taskExecutor" pool-size="5" keep-alive="120" queue-capacity="500"/>
<bean id="producerProperties"
    class="org.springframework.beans.factory.config.PropertiesFactoryBean">
    <property name="properties">
        <props>
            <prop key="topic.metadata.refresh.interval.ms">3600000</prop>
            <prop key="message.send.max.retries">5</prop>
            <prop key="serializer.class">kafka.serializer.StringEncoder</prop>
            <prop key="request.required.acks">1</prop>
        </props>
    </property>
</bean>

<int-kafka:producer-context id="kafkaProducerContext"
    producer-properties="producerProperties">
    <int-kafka:producer-configurations>
        <int-kafka:producer-configuration broker-list="127.0.0.1:9092"
                   topic="test"
                   compression-codec="default"/>
    </int-kafka:producer-configurations>
</int-kafka:producer-context>

The console show that :

Line 43 in XML document from file [/Users/zhanghui/Downloads/work/SVN/DBNService/web/WEB-INF/classes/config/spring/applicationContext-kafka.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 43; columnNumber: 35; cvc-complex-type.3.2.2: element 'int-kafka:producer-configuration' is not allowed to have the argument 'compression-codec'。

So anyone who knows how should I set the values to avoid this?


回答1:


The attribute is called compression-type:

<xsd:attribute name="compression-type" use="optional" type="xsd:string">
    <xsd:annotation>
        <xsd:documentation><![CDATA[
             Indicates the type of compression codec used for message compression.
        ]]></xsd:documentation>
    </xsd:annotation>
</xsd:attribute>

Has been renamed between 1.1 and 1.2 Spring Integration Kafka versions.



来源:https://stackoverflow.com/questions/34366823/spring-integration-kafka-xml-argument-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!