简体   繁体   English

使用 Confluent.Kafka 从 .net 核心服务写入 Kafka

[英]Writing to Kafka from .net core service using Confluent.Kafka

I have a .net core service that fetches data from a MEMSQL server and returns to the client.我有一个 .net 核心服务,它从 MEMSQL 服务器获取数据并返回给客户端。 However, the queries that are generated at the service needs to be logged to Kafka cluster.但是,服务生成的查询需要记录到 Kafka 集群。

I tried installing Confluent.Kafka package and do the logging, it works fine when running locally.我尝试安装 Confluent.Kafka 包并进行日志记录,在本地运行时效果很好。 But in the container, the service cannot log and generate the following errors:但是在容器中,该服务无法记录并产生以下错误:

 warning NU1701: Package 'librdkafka.redist 0.9.5' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
The type initializer for 'Confluent.Kafka.Impl.LibRdKafka' threw an exception.

The container is running on a LINUX machine.容器在 LINUX 机器上运行。 Basically, I need to figure out a version of Confluent.Kafka that works with .netcore 2.0 and one that does not depend on .NETFramework v4.6.基本上,我需要找出适用于 .netcore 2.0 的 Confluent.Kafka 版本和不依赖于 .NETFramework v4.6 的版本。

This warning is harmless - it occurs because librdkafka.redist does not contain any managed code and so nuget can't determine what the target framework is.此警告是无害的 - 发生它是因为 librdkafka.redist 不包含任何托管代码,因此 nuget 无法确定目标框架是什么。 This warning has been fixed in the upcoming release which we should have out within about a week.此警告已在即将发布的版本中修复,我们应该会在大约一周内发布。

Updating to the latest Confluent Package 0.11.3 fixed the issue.更新到最新的 Confluent Package 0.11.3 解决了这个问题。 Now the service is able to access Kafka cluster from the docker container.现在该服务可以从 docker 容器访问 Kafka 集群。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM