Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/Transports/Kafka/Wolverine.Kafka/Internals/KafkaListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public KafkaListener(KafkaTopic topic, ConsumerConfig config,
var envelope = mapper!.CreateEnvelope(result.Topic, message);
envelope.Offset = result.Offset.Value;
envelope.MessageType ??= _messageTypeName;
if (topic.StampConsumerGroupIdOnEnvelope) envelope.GroupId = config.GroupId;

if (topic.StampConsumerGroupIdOnEnvelope)
envelope.GroupId = config.GroupId;

await receiver.ReceivedAsync(this, envelope);
}
Expand Down Expand Up @@ -105,10 +107,11 @@ public ValueTask DeferAsync(Envelope envelope)
return _receiver.ReceivedAsync(this, envelope);
}

public ValueTask DisposeAsync()
public async ValueTask DisposeAsync()
{
Dispose();
return ValueTask.CompletedTask;
await StopAsync();
_consumer.SafeDispose();
_runner.Dispose();
}

public Uri Address { get; }
Expand Down Expand Up @@ -165,6 +168,8 @@ public async Task MoveToErrorsAsync(Envelope envelope, Exception exception)

public void Dispose()
{
_cancellation.Cancel();
_runner.Wait();
_consumer.SafeDispose();
_runner.Dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public KafkaTopicGroupListener(KafkaTopicGroup endpoint, ConsumerConfig config,

var envelope = mapper!.CreateEnvelope(result.Topic, message);
envelope.Offset = result.Offset.Value;
if (endpoint.StampConsumerGroupIdOnEnvelope) envelope.GroupId = config.GroupId;

if (endpoint.StampConsumerGroupIdOnEnvelope)
envelope.GroupId = config.GroupId;

await receiver.ReceivedAsync(this, envelope);
}
Expand Down Expand Up @@ -101,10 +103,11 @@ public ValueTask DeferAsync(Envelope envelope)
return _receiver.ReceivedAsync(this, envelope);
}

public ValueTask DisposeAsync()
public async ValueTask DisposeAsync()
{
Dispose();
return ValueTask.CompletedTask;
await StopAsync();
_consumer.SafeDispose();
_runner.Dispose();
}

public Uri Address { get; }
Expand Down Expand Up @@ -162,6 +165,8 @@ public async Task MoveToErrorsAsync(Envelope envelope, Exception exception)

public void Dispose()
{
_cancellation.Cancel();
_runner.Wait();
_consumer.SafeDispose();
_runner.Dispose();
}
Expand Down
Loading