264.2. 内容类型格式(从 Camel 2.19开始)

可以解析 JSON 消息,将其转换为 protobuf 格式,并使用原生 util converter 重新解析。要使用这个选项,将 contentTypeFormat 值设置为 'json',或调用 protobuf with second 参数。如果没有指定默认实例,请始终使用原生 protobuf 格式。示例代码显示如下:

from("direct:marshal")
    .unmarshal()
    .protobuf("org.apache.camel.dataformat.protobuf.generated.AddressBookProtos$Person", "json")
    .to("mock:reverse");