-
-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added EventEnvelopeExtensions for Kafka message deserialisation and a…
…ligned with EventStoreDB subscription to all to ignore messages that's not able to deserialise
- Loading branch information
1 parent
db4e782
commit 89c7d1d
Showing
6 changed files
with
53 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Confluent.Kafka; | ||
using Core.Events; | ||
using Core.Reflection; | ||
using Core.Serialization.Newtonsoft; | ||
|
||
namespace Core.Kafka.Events; | ||
|
||
public static class EventEnvelopeExtensions | ||
{ | ||
public static IEventEnvelope? ToEventEnvelope(this ConsumeResult<string, string> message) | ||
{ | ||
var eventType = TypeProvider.GetTypeFromAnyReferencingAssembly(message.Message.Key); | ||
|
||
if (eventType == null) | ||
return null; | ||
|
||
var eventEnvelopeType = typeof(EventEnvelope<>).MakeGenericType(eventType); | ||
|
||
// deserialize event | ||
return message.Message.Value.FromJson(eventEnvelopeType) as IEventEnvelope; | ||
} | ||
} |
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