Apache Camel:pollEnrich 不调用动态 URI

Apache Camel: pollEnrich does not call dynamic URI

我有一个从服务器轮询电子邮件的路由。在 FunctionRoute 中,我试图在 EmailPollingRoute 中使用 pollEnrich 方法通过 IMAP 协议传递我想获取的电子邮件的主题。目前我在制作动态 URI 端点时遇到问题。我注意到 headers 在调用 pollEnrich 方法之前被清除了。因此我尝试使用 ${exchangeProperty.subject} 但没有提取电子邮件。当我直接在端点中将主题设置为字符串时,将提取电子邮件。

如何在 pollEnrich 方法中动态设置主题?主题正在从 FunctionRoute 传递到 EmailPollingRoute 路线。

感谢任何帮助

@Component
public class FunctionRoute extends EmailPollingRoute {
    
    static final Logger LOGGER = LoggerFactory.getLogger(FunctionRoute.class);
    
    
    @Override
    public void configure() throws Exception {
        from("direct:process_polling_email_function")
        .process(new Processor() {
            @Override
            public void process(Exchange exchange) throws Exception {
                subject = "ABCD - Test1";
                exchange.setProperty("ABCD - Test1");
                LOGGER.info("1. subject - " + subject);
                
            }})                          
        //.setProperty("subject", constant("ABCD - Test1"))
        //.setHeader("subject", simple("ABCD - Test1"))
        .to("direct:process_polling_email");
    }

}
@Component
public class EmailPollingRoute extends BaseRouteBuilder {
    
    static final Logger LOGGER = LoggerFactory.getLogger(EmailPollingRoute.class);
        
    public String subject;
    
    @Override
    public void configure() throws Exception {
            
        //super.configure();
        //2362
    
        //@formatter:off
        from("direct:process_polling_email")
            .routeId("routeId_EmailPollingRoute")
            .process(new Processor() {
                @Override
                public void process(Exchange exchange) throws Exception {
                
                     subject = exchange.getProperty("subject", String.class);
                     LOGGER.info("0001 - subjectB: (" + subject + ")");
                    
                }})
            
            .pollEnrich("imaps://XXXXXXX.info"
                    + "?username=XXXXX&"
                    + "password=XXXXXXX&"
                    +"folderName=Inbox/Test&"
                    +"searchTerm.fromSentDate=now-72h&"
                        +"searchTerm.subject=${exchangeProperty.subject}&"
                        +"fetchSize=1");
                    
            .to("log:newmail");
            
            //@formatter:on
        
    }
}

您可以使用简单的方法动态设置 pollEnrich URI,您也可以通过类似的方式指定超时。

.pollEnrich()
    .simple("imaps://XXXXXXX.info"
        + "?username=XXXXX&"
        + "password=XXXXXXX&"
        +"folderName=Inbox/Test&"
        +"searchTerm.fromSentDate=now-72h&"
        +"searchTerm.subject=${exchangeProperty.subject}&"
        +"fetchSize=1")
    .timeout(1000);