如何在驼峰路线中引用电子邮件的主题

时间:2015-05-04 13:35:56

标签: java apache-camel javamail

我正在尝试创建一条路由,根据收到的电子邮件主题将邮件发送到不同的端点。

如何在RouteBuilder中引用主题。

我尝试了标题(“主题”)。isEqualTo(...)并且它无效

2 个答案:

答案 0 :(得分:1)

如何使用自定义SearchTerm?它可以从Camel 2.11获得。来自Camel docs:
You can configure a searchTerm on the MailEndpoint which allows you to filter out unwanted mails.
Java示例:

// we just want the unseen mails which is not spam
SearchTermBuilder builder = new SearchTermBuilder();

builder.unseen().body(Op.not, "Spam").subject(Op.not, "Spam")
  // which was sent from either foo or bar
  .from("foo@somewhere.com").from(Op.or, "bar@somewhere.com");
  // .. and we could continue building the terms

SearchTerm term = builder.build();

答案 1 :(得分:0)

这对我有用:

choice()
    .when(header("subject").isEqualTo("My Subject")).log("YES: ${header.subject}").to("direct:subroute1")
    .otherwise().log("NO: ${header.subject}").to("direct:subroute2");