dotnetcore / CAP

Distributed transaction solution in micro-service base on eventually consistency, also an eventbus with Outbox pattern
http://cap.dotnetcore.xyz
MIT License
6.61k stars 1.28k forks source link

DotNetCore.CAP.Kafka consumer vulnerable to headerless messages #1561

Closed Ekkeir closed 2 months ago

Ekkeir commented 2 months ago

When testing DotNetCore.CAP.Kafka in various scenarios I came across a scenario where consumer ends up endlessly trying to process the same message.

Scenario:

Expected behaviour:

Observed behavior:

An exception occurred when process received message. Message:'{0}'.

System.Collections.Generic.KeyNotFoundException: The given key 'cap-msg-id' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at DotNetCore.CAP.Internal.ConsumerRegister.<>c__DisplayClass22_0.<<RegisterMessageProcessor>b__0>d.MoveNext()

"0":"DotNetCore.CAP.Messages.TransportMessage"
yang-xiaodong commented 2 months ago

This is the design, CAP is the necessary header information needed to recognize external messages, look up the docs

https://cap.dotnetcore.xyz/user-guide/en/cap/messaging/#heterogeneous-system-integration

Ekkeir commented 2 months ago

I see, so the expectation is that we setup CustomHeadersBuilder deleagte for headerless messages. Thank you.