。我正在使用數據流來處理這些日誌並將相關列存儲在BigQuery中。可有人請與發佈 - 訂閱消息負載的一個LogEntry
對象轉換幫助。 我曾嘗試下面的代碼:如何發佈 - 訂閱有效載荷轉換爲LogEntry對象已啓用了日誌出口到一家酒吧子課題原木出口
@ProcessElement
public void processElement(ProcessContext c) throws Exception {
PubsubMessage pubsubMessage = c.element();
ObjectMapper mapper = new ObjectMapper();
byte[] payload = pubsubMessage.getPayload();
String s = new String(payload, "UTF8");
LogEntry logEntry = mapper.readValue(s, LogEntry.class);
}
但我得到了以下錯誤:
com.fasterxml.jackson.databind.JsonMappingException: Can not find a (Map) Key deserializer for type [simple type, class com.google.protobuf.Descriptors$FieldDescriptor]
編輯: 我嘗試下面的代碼:
try {
ByteArrayInputStream stream = new ByteArrayInputStream(Base64.decodeBase64(pubsubMessage.getPayload()));
LogEntry logEntry = LogEntry.parseDelimitedFrom(stream);
System.out.println("Log Entry = " + logEntry);
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
}
,但我得到以下現在的錯誤:
com.google.protobuf.InvalidProtocolBufferException: Protocol message end-group tag did not match expected tag