1

我有一条看起来像这样的骆驼路线:

        from("rss:" + RSS_URL)
        .marshal().rss()
        .choice()
            .when(xpath("//item/guid/text()[contains(.,'4552')]"))
                .log("Cool")
                .to("seda:end")
            .otherwise()
                .log("Other message")
                .to("seda:end");

当我检查日志时,我只看到一条消息

[example.com/feed/] route1 INFO 其他消息

如果我将 替换choicefilter指令并将 aprocess放入其中,我的过滤器确实可以工作:

        from("rss:" + RSS_URL)
        .marshal().rss()
        .filter().xpath("//item/guid/text()[contains(.,'4552')]")
        .process(new Processor() {
        @Override
        public void process(Exchange exchange) throws Exception {
            System.out.println("Got Here");
        }
    })
        .to("seda:end");

果然,我在控制台中看到了“Got Here”。更糟糕的是,如果我将 my 替换process(...)为 justlog("Cool")我会在日志中收到消息,指出过滤器匹配为 false 并且我在任何地方都看不到“Cool”......我不明白。

谁能告诉发生了什么?

4

1 回答 1

1

你用的是哪个版本的骆驼?您是否尝试使用 endChoice() DSL 来标记选择块?

from("rss:" + RSS_URL)
    .marshal().rss()
    .choice()
        .when(xpath("//item/guid/text()[contains(.,'4552')]"))
            .log("Cool")
            .to("seda:end")
        .endChoice()
        .otherwise()
            .log("Other message")
        .endChoice()
        .to("seda:end");
于 2013-07-16T08:24:07.907 回答