2017-06-29 17 views
0

我一直在尝试通过C#Apache Kafka Confluent API查找连接到IBM Message Hub的文档,但尚未成功。 github的官方回购没有C#的样本。任何人都可以使用C#与ibm消息中心进行通信,如果是,您是否可以共享该流程?IBM消息集线器与C#汇合api的沟通

谢谢。

更新: 我已经成功地与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

Config:

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为我提供了非常需要的信息。

回答

1

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

Confluent C#Kafka客户端是C库librdkafka的一个包装,直到版本0.9.5(写这篇文章时的最后一个版本)无法为Windows构建,而SASL_SSL支持是进行身份验证所必需的消息中心。

然而,随着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在安装/usr/local/etc/openssl)。来自Ubuntu的cert.pem(在/etc/openssl中找到)应该也可以工作。

祝你好运,请让我更新你的进度,

+0

谢谢Edoardo。我将研究上述内容并更新此主题上的进度。 –

+0

可以分享到哪里放置在Windows中,我不断收到错误,“无法验证经纪人证书:无法获得本地发行人证书”。 –

+0

更新:我添加了使用openssl生成的cert.pem文件的路径。我正在使用的库是Confluent.Kafka.dll版本:0.11.0预发布。我正在接受Acessviolation例外。你能帮忙吗? –