Apache kafka Spring集成—ApacheActiveMQ到Kafka
我使用以下配置将activemq与kafka集成。我从activemq接收消息并将其转发给kafka。然而,我注意到消息正在从JMS队列中退出队列,但消息不会发送到kafkaApache kafka Spring集成—ApacheActiveMQ到Kafka,apache-kafka,spring-integration,activemq,spring-transactions,Apache Kafka,Spring Integration,Activemq,Spring Transactions,我使用以下配置将activemq与kafka集成。我从activemq接收消息并将其转发给kafka。然而,我注意到消息正在从JMS队列中退出队列,但消息不会发送到kafka <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instanc
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jms="http://www.springframework.org/schema/integration/jms"
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:int-kafka="http://www.springframework.org/schema/integration/kafka"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration/jms
http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
http://www.springframework.org/schema/integration/kafka
http://www.springframework.org/schema/integration/kafka/spring-integration-kafka.xsd">
<jms:message-driven-channel-adapter
id="helloJMSAdapater" destination="helloJMSQueue" connection-factory="jmsConnectionfactory"
channel="helloChannel" extract-payload="true" />
<integration:channel id="helloChannel" />
<integration:service-activator id="sayHelloServiceActivator"
input-channel="helloChannel" ref="sayHelloService" method="sayHello" />
<int-kafka:outbound-channel-adapter
id="kafkaOutboundChannelAdapter" kafka-template="template"
auto-startup="false" sync="true" channel="helloChannel" topic="test1234"
>
</int-kafka:outbound-channel-adapter>
<bean id="template" class="org.springframework.kafka.core.KafkaTemplate">
<constructor-arg>
<bean class="org.springframework.kafka.core.DefaultKafkaProducerFactory">
<constructor-arg>
<map>
<entry key="bootstrap.servers" value="localhost:9092" />
<!--entry key="retries" value="5" /> <entry key="batch.size" value="16384"
/> <entry key="linger.ms" value="1" /> <entry key="buffer.memory" value="33554432"
/> < entry key="key.serializer" value="org.apache.kafka.common.serialization.StringSerializer"
/> <entry key="value.serializer" value="org.apache.kafka.common.serialization.StringSerializer"
/ -->
</map>
</constructor-arg>
</bean>
</constructor-arg>
</bean>
</beans>
此外,如果卡夫卡有任何问题,它甚至不会报告任何异常堆栈跟踪
我错过了什么吗?您的邮件已被SayHelloService Activator使用 因此,将helloChannel频道类型更改为
<publish-subscribe-channel id="helloChannel"/>
默认为DirectChannel
DirectChannel具有点对点语义,但在其他方面更为复杂
类似于PublishSubscribeChannel,而不是任何基于队列的
上面描述的通道实现。它实现了
SubscribableChannel接口而不是PollableChannel
接口,因此它直接向订阅者发送消息。作为一个
但是,点到点通道不同于
PublishSubscribeChannel,因为它只将每条消息发送给
单个订阅的MessageHandler
正如@Hassen Bennour所说,如果你想向两个消费者发送消息,你需要一个发布/订阅频道 也就是说,您在kafka适配器上有
auto startup=“false”
,因此它甚至不会订阅该频道
如果启动,当前配置消息将轮流发送到服务激活器和适配器。我不太了解Spring,但在Kafka中,您需要配置acks=all,以便在代理存储消息时获得acks。如果acks=0,您将不会收到提交邮件成功或失败的确认。谢谢您的评论。我注意到我的serviceActivator是void类型的,因此它不能继续使用。我现在可以从jms向卡夫卡发送消息了。谢谢你的意见。谢谢你的评论。我注意到我的serviceActivator是void类型的,因此它不能继续使用。我现在可以从jms向卡夫卡发送消息了。谢谢你的意见。