380.3. 使用 SnakeYAML 库的 YAML 数据格式
将对象消息转换为 yaml,然后发送到 MQSeries
from("activemq:My.Queue") .marshal().yaml() .to("mqseries:Another.Queue");
from("activemq:My.Queue") .marshal().yaml(YAMLLibrary.SnakeYAML) .to("mqseries:Another.Queue");
限制要从 YAML 加载的类
// Creat a SnakeYAMLDataFormat instance SnakeYAMLDataFormat yaml = new SnakeYAMLDataFormat(); // Restrict classes to be loaded from YAML yaml.addTypeFilters(TypeFilters.types(MyPojo.class, MyOtherPojo.class)); from("activemq:My.Queue") .unmarshal(yaml) .to("mqseries:Another.Queue");