dllnotfoundexception

ctrmrzij  于 2021-06-04  发布在  Kafka
关注(0)|答案(0)|浏览(198)

我在mac上使用unity3d中的Kafka有问题。
我按照解决方案中的步骤获取unity3d中的kafka:kafka integration in unity3d抛出win32exception错误
当我尝试设置消费者时,会出现以下错误:

DllNotFoundException: kernel32
Confluent.Kafka.Impl.Librdkafka.Initialize (System.String userSpecifiedPath) (at /Users/user/Desktop/confluent-kafka-dotnet-1.1.0/src/Confluent.Kafka/Impl/LibRdKafka.cs:376)
Confluent.Kafka.Consumer`2[TKey,TValue]..ctor (Confluent.Kafka.ConsumerBuilder`2[TKey,TValue] builder) (at /Users/user/Desktop/confluent-kafka-dotnet-1.1.0/src/Confluent.Kafka/Consumer.cs:537)
Confluent.Kafka.ConsumerBuilder`2[TKey,TValue].Build () (at /Users/user/Desktop/confluent-kafka-dotnet-1.1.0/src/Confluent.Kafka/ConsumerBuilder.cs:360)
KafkaConsumer.RunConsume (System.String brokerList, System.Collections.Generic.List`1[T] topics, System.Threading.CancellationToken cancellationToken) (at Assets/KafkaConsumer.cs:43)
KafkaConsumer.StartConsume () (at Assets/KafkaConsumer.cs:19)
KafkaConsumer.Start () (at Assets/KafkaConsumer.cs:13)

我尝试在VisualStudioCommunity2019中构建.dll文件,从bin中复制.dll。我还解压缩了nuget包,并尝试了那些.dll。
我试过1.1.0和1.2.0两个版本。
我还打印了librdkafka.dll在加载失败之前的路径,路径是正确的。
这是我的消费代码:

ConsumerConfig config = new ConsumerConfig
        {
            BootstrapServers = brokerList,
            GroupId = "csharp-consumer",
            EnableAutoCommit = false,
            StatisticsIntervalMs = 5000,
            SessionTimeoutMs = 6000,
            AutoOffsetReset = AutoOffsetReset.Earliest,
            EnablePartitionEof = true
        };
        const int commitPeriod = 5;
        using (var consumer = new ConsumerBuilder<Ignore, string>(config)
            // Note: All handlers are called on the main .Consume thread.
            .SetErrorHandler((_, e) => Console.WriteLine($"Error: {e.Reason}"))
            .SetStatisticsHandler((_, json) => Console.WriteLine($"Statistics: {json}"))
            .SetPartitionsAssignedHandler((c, partitions) =>
            {
                Console.WriteLine($"Assigned partitions: [{string.Join(", ", partitions)}]");
                    // possibly manually specify start offsets or override the partition assignment provided by
                    // the consumer group by returning a list of topic/partition/offsets to assign to, e.g.:
                    // 
                    // return partitions.Select(tp => new TopicPartitionOffset(tp, externalOffsets[tp]));
                })
            .SetPartitionsRevokedHandler((c, partitions) =>
            {
                Console.WriteLine($"Revoking assignment: [{string.Join(", ", partitions)}]");
            })
            .Build())
        {

任何帮助都将不胜感激!

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题