-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87c6bb5
commit c4cf0f4
Showing
12 changed files
with
147 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
title: Kafka Events | ||
permalink: /docs/advanced/kafka-events | ||
toc: false | ||
--- | ||
|
||
To let you catch the Kafka events (fired for example when the partions are assigned or revoked) they are mapped to some events that are published to the internal bus. | ||
|
||
Event | Description | ||
:-- | :-- | ||
`KafkaPartitionsAssignedEvent` | The event fired when a new consumer group partition assignment has been received by a consumer. Corresponding to each of this events there will be a `KafkaPartitionsRevokedEvent`. | ||
`KafkaPartitionsRevokedEvent` | The event fired prior to a group partition assignment being revoked. Corresponding to each of this events there will be a `KafkaPartitionsAssignedEvent`. | ||
`KafkaOffsetsCommittedEvent` | The event fired to report the result of the offset commits. | ||
`KafkaErrorEvent` | The event fired when an error is reported by the `Confluent.Kafka.Consumer` (e.g. connection failures or all brokers down). Note that the system (either the Kafka client itself or Silverback) will try to automatically recover from all errors automatically, so these errors have to be considered purely informational. | ||
`KafkaStatisticsEvent` | The event fired when statistics are received. Statistics are provided as a JSON formatted string as defined in the [librdkafka documentation](https://github.com/edenhill/librdkafka/blob/master/STATISTICS.md). You can enable statistics and set the statistics interval using the `StatisticsIntervalMs` configuration parameter (disabled by default). | ||
|
||
```c# | ||
public class KafkaEventsSubscriber : ISubscriber | ||
{ | ||
public void OnPartitionsAssigned(KafkaPartitionsAssignedEvent message) | ||
{ | ||
... | ||
} | ||
|
||
public void OnPartitionsRevoked(KafkaPartitionsRevokedEvent message) | ||
{ | ||
... | ||
} | ||
|
||
public void OnOffsetCommitted(KafkaOffsetsCommittedEvent message) | ||
{ | ||
... | ||
} | ||
|
||
public void OnError(KafkaErrorEvent message) | ||
{ | ||
... | ||
} | ||
|
||
public void OnStatisticsReceived(KafkaStatisticsEvent message) | ||
{ | ||
... | ||
} | ||
} | ||
``` |
10 changes: 10 additions & 0 deletions
10
src/Silverback.Integration.Kafka/Messaging/Messages/IKafkaEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (c) 2019 Sergio Aquilini | ||
// This code is licensed under MIT license (see LICENSE file for details) | ||
|
||
namespace Silverback.Messaging.Messages | ||
{ | ||
public interface IKafkaEvent : ISilverbackEvent | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/Silverback.Integration.Kafka/Messaging/Messages/KafkaStatisticsEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2019 Sergio Aquilini | ||
// This code is licensed under MIT license (see LICENSE file for details) | ||
|
||
namespace Silverback.Messaging.Messages | ||
{ | ||
/// <summary> | ||
/// The event fired when statistics are received. Statistics are provided as a JSON formatted string | ||
/// as defined here: https://github.com/edenhill/librdkafka/blob/master/STATISTICS.md | ||
/// </summary> | ||
/// <remarks> | ||
/// You can enable statistics and set the statistics interval using the <c>StatisticsIntervalMs</c> | ||
/// configuration parameter (disabled by default). | ||
/// </remarks> | ||
public class KafkaStatisticsEvent : IMessage | ||
{ | ||
public KafkaStatisticsEvent(string json) | ||
{ | ||
Json = json; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the statistics JSON (see https://github.com/edenhill/librdkafka/blob/master/STATISTICS.md) | ||
/// </summary> | ||
public string Json { get; } | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
src/Silverback.Integration.Kafka/Messaging/Messages/StatisticsEvent.cs
This file was deleted.
Oops, something went wrong.