我是rabbitmq和protobuf的新手,是否有一些代码示例可以用C语言通过Rabbitmq发送和接收protobuf数据?谢谢
下面的代码有效:
Operation msg = OPERATION__INIT;
uint8_t *buf;
unsigned len;
msg.operation = (char *)operations[j].operation;
msg.tracking_id = operations[j].tracking_id;
msg.x = operations[j].x;
msg.y = operations[j].y;
msg.pressure = operations[j].pressure;
msg.has_tracking_id = 1;
msg.has_x = 1;
msg.has_y = 1;
msg.has_pressure = 1;
len = operation__get_packed_size(&msg);
buf = malloc(len);
operation__pack(&msg, buf);
amqp_basic_publish(conn, 1, amqp_cstring_bytes(exchange),amqp_cstring_bytes(routingkey), 0, 0, &props, amqp_cstring_bytes(buf));