I’m building a data pipeline with UE4 at the end for visualization and AR/VR interactivity. There’s a lot of data and processing to prepare it for UE4 so the pipeline is built around Kafka. I have been working on importing the cppkafka library (GitHub - mfontanini/cppkafka: Modern C++ Apache Kafka client library (wrapper for librdkafka)</tit) - a wrapper for the librdkafka Kafka library - into UE4. It’s been challenging, but I thought it was mostly there until a few days ago.
I’m using an FTimer driven function to poll for new messages every n seconds, which needs a cppkafka::Consumer object to do the polling. I want to pass the Consumer object into the timer function so that I don’t need to keep setting it up and subscribing to topics every time the timer fires, and this is where things break down.
Trying to compile gives me the error: [FONT=courier new]Cannot find class ‘’, to resolve delegate ‘Consumer’. Is what I’m trying to do possible? Can I pass a non-UObject object into a UFunction? If so, any advice on how to accomplish this? And if not, are there any options to achieve the same outcome in a different way?
BTW, a barebones project is at https://github.com/oluf/DataStreaming_UE4. It’s mostly useless without some documentation and context, but if anyone is interested let me know, I’m happy to share what I’ve learned.
// AConsumerOne header (actor class)
UFUNCTION()
void ConsumerRunLoop(cppkafka::Consumer consumer);
// AConsumerOne implementation (actor)
void AConsumerOne::BeginPlay()
{
Super::BeginPlay();
cppkafka::Configuration kafkaConfig = {
{ "metadata.broker.list", "192.168.0.179:9092" },
// { "debug", "all" },
{ "group.id", "defaultgroup" }
};
cppkafka::Consumer kafkaConsumer(kafkaConfig);
kafkaConsumer.subscribe({ "test" });
FTimerDelegate ConsumerTimerDelegate;
ConsumerTimerDelegate.BindUFunction(this, FName("ConsumerRunLoop"), &kafkaConsumer);
FTimerHandle ConsumerTimerHandle;
GetWorldTimerManager().SetTimer(ConsumerTimerHandle, ConsumerTimerDelegate, 5.f, true, 0.f);
}
void AConsumerOne::ConsumerRunLoop(cppkafka::Consumer consumer) {
cppkafka::Message msg = consumer.poll();
// Do stuff here
}