Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mempko
Created December 30, 2015 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mempko/fc3f89d179d9a33a750d to your computer and use it in GitHub Desktop.
Save mempko/fc3f89d179d9a33a750d to your computer and use it in GitHub Desktop.
Example usage of Perl 6 Kafka library in progress.
use v6;
use lib 'lib/kafka';
use Kafka;
sub MAIN ()
{
my $consumer = Kafka::Consumer.new( topic=>"test", brokers=>"192.168.0.5");
$consumer.messages.tap(-> $msg
{
given $msg
{
when Kafka::Message
{
say "got {$msg.offset}: { $msg.payload } ";
}
when Kafka::EOF
{
say "Messages Consumed { $msg.total-consumed}";
$consumer.stop;
}
when Kafka::Error
{
say "Error {$msg.what}";
$consumer.stop;
}
}
});
await $consumer.consume-from-beginning(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment