Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duplicate header error #1620

Closed
PoteRii opened this issue Dec 4, 2024 · 6 comments
Closed

duplicate header error #1620

PoteRii opened this issue Dec 4, 2024 · 6 comments

Comments

@PoteRii
Copy link
Contributor

PoteRii commented Dec 4, 2024

Hello, we are getting following exception: An item with the same key has already been added. Key: cap-msg-group

at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at DotNetCore.CAP.Kafka.KafkaConsumerClient.Consume(ConsumeResult2 consumerResult)
at DotNetCore.CAP.Kafka.KafkaConsumerClient.Listening(TimeSpan timeout, CancellationToken cancellationToken)
at DotNetCore.CAP.Internal.ConsumerRegister.<>c__DisplayClass21_1.b__2()

image

This causes consumer to crash, decreases members of kafka consumer and thus increases lag (messages behind). We are not modifying headers and I could not find a message in DB with duplicate cap-msg-group header

any ideas for the cause?

@PoteRii PoteRii closed this as completed Dec 4, 2024
@PoteRii
Copy link
Contributor Author

PoteRii commented Dec 4, 2024

turn out one of our provider produced an invalid message, which already contained cap-msg-group header. Can we move CustomerHeadersBuilder on top of other logic so such cases can be handled by it?

@PoteRii PoteRii reopened this Dec 4, 2024
@yang-xiaodong
Copy link
Member

Each has its own benefits, and placing them on top offers the possibility of rewriting Group.

Whether or not to place the headers.Add(Headers.Group, _groupId) to headers[Headers.Group] =_groupId looks good?

@PoteRii
Copy link
Contributor Author

PoteRii commented Dec 4, 2024

yes, that is also an option, since other implementations (e.g. Redis) use that approach as well

@yang-xiaodong
Copy link
Member

yes, that is also an option, since other implementations (e.g. Redis) use that approach as well

Would you want to make a PR?

@PoteRii
Copy link
Contributor Author

PoteRii commented Dec 4, 2024

sure

@yang-xiaodong
Copy link
Member

Fixed in v8.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants