can send ess streaming data types flatbuffer messages via kafka
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "asynOctetSyncIO.h"
|
||||
#include "ev42_events_generated.h"
|
||||
#include <cstring>
|
||||
#include <epicsStdio.h>
|
||||
#include <iocsh.h>
|
||||
@@ -140,14 +141,24 @@ asynStreamGeneratorDriver::asynStreamGeneratorDriver(const char *portName,
|
||||
}
|
||||
|
||||
char *msg = "asdf\n";
|
||||
// EventMessageBuilder b;
|
||||
// We could I believe reuse a buffer which might be more performant.
|
||||
flatbuffers::FlatBufferBuilder builder(1024);
|
||||
std::vector<uint32_t> tof = {1, 2, 3};
|
||||
std::vector<uint32_t> did = {0, 0, 0};
|
||||
auto message =
|
||||
CreateEventMessageDirect(builder, "monitor1", 0, 0, &tof, &did);
|
||||
|
||||
rd_kafka_resp_err_t err =
|
||||
rd_kafka_producev(producer, RD_KAFKA_V_TOPIC("NEWEFU_TEST"),
|
||||
RD_KAFKA_V_MSGFLAGS(RD_KAFKA_MSG_F_COPY),
|
||||
// RD_KAFKA_V_KEY((void *)key, key_len),
|
||||
RD_KAFKA_V_VALUE((void *)msg, 6),
|
||||
// RD_KAFKA_V_OPAQUE(NULL),
|
||||
RD_KAFKA_V_END);
|
||||
builder.Finish(message, "ev42");
|
||||
printf("buffer size: %d\n", builder.GetSize());
|
||||
|
||||
rd_kafka_resp_err_t err = rd_kafka_producev(
|
||||
producer, RD_KAFKA_V_TOPIC("NEWEFU_TEST"),
|
||||
RD_KAFKA_V_MSGFLAGS(RD_KAFKA_MSG_F_COPY),
|
||||
// RD_KAFKA_V_KEY((void *)key, key_len),
|
||||
RD_KAFKA_V_VALUE((void *)builder.GetBufferPointer(), builder.GetSize()),
|
||||
// RD_KAFKA_V_OPAQUE(NULL),
|
||||
RD_KAFKA_V_END);
|
||||
|
||||
if (err) {
|
||||
// TODO
|
||||
|
||||
Reference in New Issue
Block a user