via community slack:
I'm trying to integrate a kafka client in a Unity3D project (based on mono).
When I try to initialize the Confluent .NET client I get an ArgumentException with "method return type is incompatible" message thrown from the CreateDelegate() in the Librdkafka.SetDelegates() method.
When I'm running my code in a .NET framework tester it runs with no problem, so I guess the mono framework used in Unity is causing the problem.
Which version? if not 1.0-beta2, please try that version, there is a small chance this was fixed by something I did recently (but I don't think so).
I don't know exactly where the problem is without testing (note: I've never used the library with mono myself). I'm concerned this may indicate a problem in the interop code that is relevant to all frameworks - it may be that the only one that picks up on this is mono. for that reason we should look into this further.
Yes, the version I'm using is 1.0.0-beta2
I think the problem is related to this line in LibRdKafka.cs:
_event_type = (Func<IntPtr, EventType>)methods.Single(m => m.Name == "rd_kafka_event_type").CreateDelegate(typeof(Func<IntPtr, EventType>));
since the method type declared in NativaMethods.cs is:
[DllImport(DllName, CallingConvention =CallingConvention.Cdecl)]
internal static extern int rd_kafka_event_type(IntPtr rkev);
I changed the int to Librdkafka.EventType and it fixed this problem for me:
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
internal static extern Librdkafka.EventType rd_kafka_event_type(IntPtr rkev);
thanks for investigating! yep, that'd do it. Will include in -beta3.
@mhowlett Can you providea detail guide/tutorial for kafka and unity3d integration?
Most helpful comment
@mhowlett Can you providea detail guide/tutorial for kafka and unity3d integration?