Spring集成Kafka XML参数错误 [英] Spring integration Kafka XML argument error

查看:27
本文介绍了Spring集成Kafka XML参数错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

kafka 和 zookeeper 工作正常,因为我已经尝试了 JAVA 生成或使用消息的基本方法,所以这里的问题是,我正在考虑在我的项目中使用 Spring 集成 Kafka,XML 文件就像这个:

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>

控制台显示:

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?

推荐答案

属性被称为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>

已在 1.11.2 Spring Integration Kafka 版本之间重命名.

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

这篇关于Spring集成Kafka XML参数错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆