Last active
March 12, 2023 07:59
-
-
Save ayeshLK/74b824180a441095c9c35c4217df97e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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