0

我一直在尝试查找通过 C# Apache Kafka Confluent API 连接到 IBM Message Hub 的文档,但没有成功。github 上的官方 repo 没有 C# 的示例。有没有人能够使用 C# 与 ibm 消息中心通信,如果是的话,你可以分享这个过程。

谢谢。

更新:我已成功与 IBM Message Hub 进行通信。

图书馆:

  1. librdkafka -... 0.11.0-RC2

  2. 证书来自:https ://curl.haxx.se/docs/caextract.html

  3. Confluent.kafka.dll Confluent.Kafka 0.11.0-RC1

配置:

private static Dictionary<string, object> constructConfig(string brokerList, bool enableAutoCommit) =>
            new Dictionary<string, object>
            {
                { "group.id", "history" },
                { "enable.auto.commit", enableAutoCommit },
                { "auto.commit.interval.ms", 5000 },
                { "statistics.interval.ms", 60000 },
                { "bootstrap.servers", "ibmserver:port" },
                { "default.topic.config", new Dictionary<string, object>()
                    {
                        { "auto.offset.reset", "smallest" }
                    }
                },
                {"ssl.ca.location",@"E:\cert\cacert.pem" },              
                {"api.version.request","true" },
                {"security.protocol","sasl_ssl" },
                {"sasl.mechanisms","PLAIN" },
                {"sasl.username","xxxx" },
                {"sasl.password","xxxxx" }

            };

.net 版本:4.5.2

希望它可以为某人节省时间。

感谢 Edoardo Comar 指导我获取急需的信息。

4

1 回答 1

1

我们还没有编写 C# 示例。

Confluent C# Kafka 客户端是 C 库的包装器,在librdkafka版本 0.9.5(撰写本文时的最后一个版本)之前,无法为 Windows 构建具有 SASL_SSL 支持的 Windows,这是对 Message Hub 进行身份验证所必需的。

但是,由于最近的一些提交,librdkafka 0.11(在发布候选版本中,因为我发布了此评论)已经改变了。

我验证了 librdkafka 0.11(主分支)能够​​通过 Windows 上的 Message Hub 进行身份验证。您将需要设置这些配置属性:

api.version.request=true
security.protocol=sasl_ssl
ssl.ca.location=<path to a valid cert.pem file>
sasl.mechanisms=PLAIN
sasl.username=<username from your Bluemix credentials>
sasl.password=<password from your Bluemix credentials>

我不知道如何在 Windows 中获取有效的 .pem 证书文件,所以我从 macOS 复制了一个 cert.pem 文件(通过 brew openssl in 安装/usr/local/etc/openssl)。cert.pem来自 Ubuntu(在 中找到)的 A/etc/openssl也应该可以工作。

祝你好运,请让我了解你的进展,

于 2017-06-29T09:53:03.353 回答