问题描述
我正在尝试在统一环境中运行Kafka的代码示例,因此,我创建了一个消费者客户端(下面给出的代码)。
I am trying to run a code sample of Kafka in unity environment and for this reason, I created a consumer client (Code given below).
<pre>using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Confluent.Kafka;
using Confluent.Kafka.Serialization;
using System.Text;
public class KafkaConsumer : MonoBehaviour {
// Use this for initialization
void Start () {
/*
The consumer application will then pick the messages from the same topic and write them to console output.
The process to create the consumer application is also very simple.
*/
var config = new Dictionary<string, object>
{
//{"group.id","sample-consumer" },
{"group.id","JavaInUseGroup" },
{"bootstrap.servers", "localhost:9092" },
{ "enable.auto.commit", "false" }
};
//using (var consumer = new Consumer<Null, string>(config, null, new StringSerializer(Encoding.UTF8)))
using (var consumer = new Consumer<Null, string>(config, null, new StringDeserializer(Encoding.UTF8)))
{
consumer.Subscribe(new string[] { "javainuse-topic" });
consumer.OnMessage += (_, msg) =>
{
//Console.WriteLine($"Topic: {msg.Topic} Partition: {msg.Partition} Offset :{msg.Offset} {msg.Value}");
Debug.Log($"Topic: {msg.Topic} Partition: {msg.Partition} Offset :{msg.Offset} {msg.Value}");
consumer.CommitAsync(msg);
};
while (true)
{
consumer.Poll(100);
}
}
}
}
我的尝试:
为了执行上面的代码示例,我还在我的项目资产文件夹中添加了confluent.Kafka dll。但每当我运行我的统一游戏时它会抛出一个错误:Win32Exception:找不到指定的模块。
What I have tried:
In order to execute the above code sample I have also added confluent.Kafka dll into my project asset folder. but whenever I run my unity game it throws an error:Win32Exception: The specified module could not be found.
Rethrow as InvalidOperationException: Error while loading librdkafka.dll or its dependencies from Assets/librdkafka.dll. Check the directory exists, if not check your deployment process. You can also load the library and its dependencies by yourself before any call to Confluent.Kafka Confluent.Kafka.Impl.LibRdKafka.Initialize (System.String userSpecifiedPath) (at <700d5bbe3b974ce5aed001c82b789f6a>:0) Confluent.Kafka.Consumer..ctor (System.Collections.Generic.IEnumerable1[T] config) (at
<700d5bbe3b974ce5aed001c82b789f6a>:0)
Confluent.Kafka.Consumer2[TKey,TValue]..ctor (System.Collections.Generic.IEnumerable1[T] config,
Confluent.Kafka.Serialization.IDeserializer1[T] keyDeserializer, Confluent.Kafka.Serialization.IDeserializer`1[T] valueDeserializer) (at <700d5bbe3b974ce5aed001c82b789f6a>:0) KafkaConsumer.Start () (at Assets/KafkaConsumer.cs:26)
推荐答案
我的尝试:
为了执行上面的代码示例,我还在我的项目资产文件夹中添加了confluent.Kafka dll。但每当我运行我的统一游戏时它会抛出一个错误:Win32Exception:找不到指定的模块。
What I have tried:
In order to execute the above code sample I have also added confluent.Kafka dll into my project asset folder. but whenever I run my unity game it throws an error:Win32Exception: The specified module could not be found.
Rethrow as InvalidOperationException: Error while loading librdkafka.dll or its dependencies from Assets/librdkafka.dll. Check the directory exists, if not check your deployment process. You can also load the library and its dependencies by yourself before any call to Confluent.Kafka Confluent.Kafka.Impl.LibRdKafka.Initialize (System.String userSpecifiedPath) (at <700d5bbe3b974ce5aed001c82b789f6a>:0) Confluent.Kafka.Consumer..ctor (System.Collections.Generic.IEnumerable1[T] config) (at
<700d5bbe3b974ce5aed001c82b789f6a>:0)
Confluent.Kafka.Consumer2[TKey,TValue]..ctor (System.Collections.Generic.IEnumerable1[T] config,
Confluent.Kafka.Serialization.IDeserializer1[T] keyDeserializer, Confluent.Kafka.Serialization.IDeserializer`1[T] valueDeserializer) (at <700d5bbe3b974ce5aed001c82b789f6a>:0) KafkaConsumer.Start () (at Assets/KafkaConsumer.cs:26)
这篇关于Win32exception:找不到指定的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!