ProtobufDataFormat 인스턴스를 생성하고 Camel DataFormat marshal 및 unmarshal API로 전달할 수 있습니다.
ProtobufDataFormat format = new ProtobufDataFormat(Person.getDefaultInstance());
from("direct:in").marshal(format);
from("direct:back").unmarshal(format).to("mock:reverse");
ProtobufDataFormat format = new ProtobufDataFormat(Person.getDefaultInstance());
from("direct:in").marshal(format);
from("direct:back").unmarshal(format).to("mock:reverse");
Copy to ClipboardCopied!Toggle word wrapToggle overflow
또는 다음과 같이 unmarshal 기본 인스턴스 또는 기본 인스턴스 클래스 이름을 전달하도록 DSL protobuf()를 사용합니다.
// You don't need to specify the default instance for protobuf marshaling
from("direct:marshal").marshal().protobuf();
from("direct:unmarshalA").unmarshal()
.protobuf("org.apache.camel.dataformat.protobuf.generated.AddressBookProtos$Person")
.to("mock:reverse");
from("direct:unmarshalB").unmarshal().protobuf(Person.getDefaultInstance()).to("mock:reverse");
// You don't need to specify the default instance for protobuf marshaling
from("direct:marshal").marshal().protobuf();
from("direct:unmarshalA").unmarshal()
.protobuf("org.apache.camel.dataformat.protobuf.generated.AddressBookProtos$Person")
.to("mock:reverse");
from("direct:unmarshalB").unmarshal().protobuf(Person.getDefaultInstance()).to("mock:reverse");
Copy to ClipboardCopied!Toggle word wrapToggle overflow