Closed lbilodeau closed 3 years ago
Hi,
Thanks for your question. The problem is the use of the Ignore type with the producer. Ignore is only supported with consumers. I realize I have an example in the README that uses that incorrectly, which I should fix!
Simply change your IProducer<Ignore, string> kafkaProducer
to IProducer<Null, string>
and it should work for you.
Cheers, Kyle
Update: Fixed in 7f91798
I've tried to follow your example in the readme.md file but when I run my code I get the following exception:
System.ArgumentNullException: Value cannot be null. (Parameter 'Key serializer not specified and there is no default serializer defined for type Ignore.') at Confluent.Kafka.Producer
2.InitializeSerializers(ISerializer
1 keySerializer, ISerializer1 valueSerializer, IAsyncSerializer
1 asyncKeySerializer, IAsyncSerializer`1 asyncValueSerializer)This error comes from the service constructor below:
public ContractManagementController( IAsyncLoggerClient logstashlogger, IConfiguration iConfig, ICluster cluster, IProducer<Ignore, string> kafkaProducer ) { _configuration = iConfig; _logstashlogger = logstashlogger; // need to pass the DI components down the workflow chain to the DAL layer BRules = new CMBR( _logstashlogger, cluster, iConfig, kafkaProducer); _logstashlogger.InitLogger(_configuration.GetValue<int>("Logstash:port"), _configuration.GetValue<string>("Logstash:hostname"), LOGGER_SOURCE); }
I only need a producer at this point so later in my service I do this:
and then to produce a message...
var pubsubresults = await msgProducer.ProduceAsync("contract_updated" , new Message<Ignore, string> { Value = JsonSerializer.Serialize(JsonContract) });