private static void DeliveryReportCallback(IntPtr rk, ref rd_kafka_message rkmessage, IntPtr opaque) { // msg_opaque was set by Topic.Produce var gch = GCHandle.FromIntPtr(rkmessage._private); var deliveryHandler = (IDeliveryHandler)gch.Target; gch.Free(); if (rkmessage.err != 0) { deliveryHandler.SetException( RdKafkaException.FromErr( rkmessage.err, "Failed to produce message")); return; } deliveryHandler.SetResult(new DeliveryReport { Offset = rkmessage.offset, Partition = rkmessage.partition }); }
static void DeliveryReportCallback(IntPtr rk, ref rd_kafka_message rkmessage, IntPtr opaque) { // msg_opaque was set by Topic.Produce var gch = GCHandle.FromIntPtr(rkmessage._private); var deliveryCompletionSource = (TaskCompletionSource <DeliveryReport>)gch.Target; gch.Free(); if (rkmessage.err != 0) { deliveryCompletionSource.SetException( RdKafkaException.FromErr( rkmessage.err, Marshal.PtrToStringAnsi(rkmessage.payload))); return; } deliveryCompletionSource.SetResult(new DeliveryReport() { Offset = rkmessage.offset, Partition = rkmessage.partition }); }