コード例 #1
0
 public KafkaMessagePublisher(
     IOptions <KafkaPublisherOptions <TOutput> > options,
     CloudEventFormatter cloudEventFormatter,
     IOptions <PublisherOptions> publisherOptions)
 {
     _cloudEventFormatter = cloudEventFormatter;
     _options             = options.Value ?? throw new ArgumentNullException(nameof(options));
     _publisherOptions    = publisherOptions.Value ?? throw new ArgumentNullException(nameof(publisherOptions));
     _producer            = new ProducerBuilder <string?, byte[]>(_options).Build();
 }
コード例 #2
0
    private static KafkaMessagePublisher <TData> GetKafkaPublisher <TData>(
        CloudEventFormat format = CloudEventFormat.Protocol)
    {
        var options = new KafkaPublisherOptions <TData>
        {
            Topic = KafkaTopic
        };

        return(new KafkaMessagePublisher <TData>(Options.Create(options), new JsonEventFormatter(),
                                                 Options.Create(new PublisherOptions {
            CloudEventFormat = format
        })));
    }