Skip to content

Instantly share code, notes, and snippets.

@ayeshLK
Last active March 12, 2023 07:59
Show Gist options
  • Save ayeshLK/74b824180a441095c9c35c4217df97e4 to your computer and use it in GitHub Desktop.
Save ayeshLK/74b824180a441095c9c35c4217df97e4 to your computer and use it in GitHub Desktop.
kafka:ProducerConfiguration messagePersistConfig = {
clientId: "message-persist-client",
acks: "1",
retryCount: 3
};
final kafka:Producer messagePersistProducer = check new ("localhost:9092", messagePersistConfig);
public isolated function publishWeatherNotification(string location, WeatherReport weatherReport) returns error? {
json payload = weatherReport.toJson();
byte[] serializedContent = payload.toJsonString().toBytes();
check messagePersistProducer->send({
topic: location,
value: serializedContent
});
check messagePersistProducer->'flush();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment