dotnetcore/CAP

NATS can not be configure cap-msg-id if receiving messages

wi-chrfaber opened this issue · 4 comments

The problem is, when the NATS server issues messages that do not have "cap-msg-id"/"cap-msg-name", the CAP library has trouble receiving the messages. And I didn't find any configuration options to put it (like Kafka for example).

Error Messages
An exception occurred when process received message. Message:'DotNetCore.CAP.Messages.TransportMessage'. System.Collections.Generic.KeyNotFoundException: The given key 'cap-msg-id' was not present in the dictionary. at DotNetCore.CAP.Internal.ConsumerRegister.<>c__DisplayClass22_0.<<RegisterMessageProcessor>b__0>d.MoveNext()

Hi @wi-chrfaber

NATS does not provide CustomHeadersBuilder option yet, would you like to submit a PR? Just like Kafka or RabbitMQ.

if (_kafkaOptions.CustomHeadersBuilder != null)
{
var customHeaders = _kafkaOptions.CustomHeadersBuilder(consumerResult, _serviceProvider);
foreach (var customHeader in customHeaders)
{
headers[customHeader.Key] = customHeader.Value;
}
}

Thank you in advance.

Hi,

Yes, create a PR for this feature.

Thanks for the quick feedback.

Hi @wi-chrfaber

Any update about the PR?

Thanks!