motornet icon indicating copy to clipboard operation
motornet copied to clipboard

Kafka Consumer disposed twice

Open rngcntr opened this issue 9 months ago • 0 comments

When disposing a MotorHost, the KafkaMessageConsumer is stopped and disposed. Both operations seem to be in conflict, judging from the exception message:

System.ObjectDisposedException: handle is destroyed
   at Confluent.Kafka.Impl.SafeKafkaHandle.ThrowIfHandleClosed()
   at Confluent.Kafka.Impl.SafeKafkaHandle.ConsumerClose()
   at Confluent.Kafka.Consumer`2.Close()
   at Motor.Extensions.Hosting.Kafka.KafkaMessageConsumer`1.StopAsync(CancellationToken token)
   at Motor.Extensions.Hosting.Consumer.TypedConsumerService`1.StopAsync(CancellationToken token)
   at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
   at Microsoft.Extensions.Hosting.Internal.Host.StopAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.WaitForShutdownAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Program.<Main>$(String[] args) in /some/private/directory/Program.cs:line 11
   at Program.<Main>(String[] args)
   at InvokeStub_Program.<Main>(Object, Span`1)
   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

rngcntr avatar Mar 13 '25 12:03 rngcntr