forked from arnaud-lb/php-rdkafka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathallow_null_payload.phpt
45 lines (35 loc) · 972 Bytes
/
allow_null_payload.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
--TEST--
Allow null payload
--SKIPIF--
<?php
require __DIR__ . '/integration-tests-check.php';
--FILE--
<?php
require __DIR__ . '/integration-tests-check.php';
$topicName = sprintf('test_rdkafka_%s', uniqid());
$producer = new RdKafka\Producer();
$producer->addBrokers(getenv('TEST_KAFKA_BROKERS'));
$topic = $producer->newTopic($topicName);
$topic->produce(0, 0, NULL, 'message_key_1');
while ($producer->getOutQLen() > 0) {
$producer->poll(50);
}
$consumer = new RdKafka\Consumer();
$consumer->addBrokers(getenv('TEST_KAFKA_BROKERS'));
$topic = $consumer->newTopic($topicName);
$topic->consumeStart(0, RD_KAFKA_OFFSET_BEGINNING);
while (true) {
$message = $topic->consume(0, 1000);
if ($message === null) {
continue;
}
if (RD_KAFKA_RESP_ERR_NO_ERROR === $message->err) {
var_dump($message->payload);
var_dump($message->key);
break;
}
}
$topic->consumeStop(0);
--EXPECTF--
NULL
string(13) "message_key_1"