Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b0fbaa0

Browse files
committed
add watermark example
1 parent e191a89 commit b0fbaa0

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
use SimpleKafkaClient\Configuration;
4+
use SimpleKafkaClient\Message;
5+
use SimpleKafkaClient\Consumer;
6+
use SimpleKafkaClient\Producer;
7+
use SimpleKafkaClient\TopicPartition;
8+
9+
error_reporting(E_ALL);
10+
11+
$conf = new Configuration();
12+
$conf->set('client.id', 'pure-php-producer');
13+
$conf->set('metadata.broker.list', 'kafka:9096');
14+
$conf->set('compression.codec', 'snappy');
15+
$conf->set('message.timeout.ms', '5000');
16+
17+
$producer = new Producer($conf);
18+
$topic = $producer->getTopicHandle('pure-php-test-topic-watermark');
19+
$time = time();
20+
$topic->producev(
21+
RD_KAFKA_PARTITION_UA,
22+
RD_KAFKA_MSG_F_BLOCK, // will block produce if queue is full
23+
'special-message',
24+
'special-key',
25+
[
26+
'special-header' => 'awesome'
27+
]
28+
);
29+
$result = $producer->flush(20000);
30+
$high = 0;
31+
$low = 0;
32+
$result = $producer->queryWatermarkOffsets('pure-php-test-topic-watermark', 0,$low, $high, 10000);
33+
34+
echo sprintf('Lowest offset is: %d, highest offset is: %d', $low, $high) . PHP_EOL;
35+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /