Skip to content

Instantly share code, notes, and snippets.

@wullemsb
Created November 15, 2020 12:57
Show Gist options
  • Save wullemsb/0906ee8c0245688b4c2a31272cd2075e to your computer and use it in GitHub Desktop.
Save wullemsb/0906ee8c0245688b4c2a31272cd2075e to your computer and use it in GitHub Desktop.
// Create a producer that can be used to send messages to kafka that have no key and a value of type PageViewEvent
using var producer = new ProducerBuilder<Null, PageViewEvent>(config)
.Build();
//Construct a message to send (generic type must match what was used above when creating the producer)
var message = new Message<Null, PageViewEvent>
{
Value = new PageViewEvent{ pageUrl=$"http://kafkaexample/{value}"}
};
await producer.ProduceAsync("kafka-topic-name", message) ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment