376.2. SnakeYAML ライブラリーで YAML データ形式を使用する

  • Object メッセージを 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");