-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow sending & reading headers via Kafka Message object. #880
Conversation
Note that `Topic::producev` & `KafkaMessage::headers` exist since phprdkafka >= 3.1.0.
Note that `Topic::producev` & `KafkaMessage::headers` exist since phprdkafka >= 3.1.0.
Note that `Topic::producev` & `KafkaMessage::headers` exist since phprdkafka >= 3.1.0.
// Note: Topic::producev method exists in phprdkafka >= 3.1.0 | ||
// Headers in payload are maintained for backwards compatibility with apps that might run on lower phprdkafka version | ||
if (method_exists($topic, 'producev')) { | ||
$topic->producev($partition, 0 /* must be 0 */, $payload, $key, $message->getHeaders()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably also should contain a check against phprdkafka version & librdkafka 1.0.0, since there is a possible segfault here.
EDIT: Well, as a matter of fact, the PR that fixes the producev
call for librdkafka 1.0.0 is not yet included in a release, so it will probably have to remain as a TODO once it does.
Related PR:
arnaud-lb/php-rdkafka#222
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added version check. I've tried it with local build from master and
var_dump(version_compare('3.1.0-dev', '3.1.0', '<=');
// false
which is the version that you will get if you build from master branch of phprdkafka.
I'm considering whether or not this check is worthwile, however otherwise it will result in hard to debug segfault.
@makasim what are you thought on this? Should it be dropped? Should it emit a warning (like here) or "drop down" to calling produce
?
A simpler part of php-enqueue#880, adds just the consumption part. This makes headers accessible in the consumer in case another application makes use of those, be it PHP or not.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Note that
Topic::producev
&KafkaMessage::headers
exist sincephprdkafka >= 3.1.0.
Resolves #843
Due to the fact that
php-enqueue/kafka
might be used with different versions of phprdkafka, I opted to maintain serializing of headers into the message.