You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-5Lines changed: 10 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -29,14 +29,14 @@ Both the `KafkaProducer` and the `KafkaConsumer` implement the [`Service`](https
29
29
30
30
### Producer API
31
31
32
-
The `send(_:)` method of `KafkaProducer` returns a message-id that can later be used to identify the corresponding acknowledgement. Acknowledgements are received through the `acknowledgements`[`AsyncSequence`](https://developer.apple.com/documentation/swift/asyncsequence). Each acknowledgement indicates that producing a message was successful or returns an error.
32
+
The `send(_:)` method of `KafkaProducer` returns a message-id that can later be used to identify the corresponding acknowledgement. Acknowledgements are received through the `events`[`AsyncSequence`](https://developer.apple.com/documentation/swift/asyncsequence). Each acknowledgement indicates that producing a message was successful or returns an error.
33
33
34
34
```swift
35
35
let broker = KafkaConfiguration.Broker(host: "localhost", port: 9092)
36
36
var config =KafkaProducerConfiguration()
37
37
config.bootstrapServers= [broker]
38
38
39
-
let (producer, acknowledgements) =try KafkaProducer.makeProducerWithAcknowledgements(
39
+
let (producer, events) =try KafkaProducer.makeProducerWithEvents(
40
40
config: config,
41
41
logger: logger
42
42
)
@@ -53,7 +53,7 @@ await withThrowingTaskGroup(of: Void.self) { group in
53
53
tryawait serviceGroup.run()
54
54
}
55
55
56
-
// Task receiving acknowledgements
56
+
// Task sending message and receiving events
57
57
group.addTask {
58
58
let messageID =try producer.send(
59
59
KafkaProducerMessage(
@@ -62,8 +62,13 @@ await withThrowingTaskGroup(of: Void.self) { group in
62
62
)
63
63
)
64
64
65
-
forawait acknowledgement in acknowledgements {
66
-
// Check if acknowledgement belongs to the sent message
65
+
forawait event in events {
66
+
switch event {
67
+
case .deliveryReports(let deliveryReports):
68
+
// Check what messages the delivery reports belong to
0 commit comments