Hi,
In my camel-context.xml definition below, the `loadEmails uri` triggers
exactly after every 5 seconds and the `emailConfigProcessor` also loads
after every 5 seconds with the values fetched from the autowired
`emailConfigBean`.
But when I enable the `<pollEnrich>` tag the timer fails to trigger
periodically. I duly verified this by commenting and un-commenting the
`<pollEnrich>`. When I commented out the `<pollEnrich>` all logs from the
`emailConfigProcessor `bean and the timer are getting printed periodically.
**camel-context.xml**
<route id="mail-route-imap" autoStartup="true">
<!-- Input to trigger the route -->
<from uri="timer://loadEmails?period=5000&fixedRate=false" />
<log message="Timer triggered!" />
<!-- Log when the timer triggers -->
<log message="Timer triggered, calling emailConfigProcessor..." />
<process ref="emailConfigProcessor" />
<log message="IMAP URL: ${exchangeProperty.imapUrl}, IMAP Port:
${exchangeProperty.imapPort}" />
<!-- Poll from IMAP dynamically using pollEnrich -->
<pollEnrich timeout="1000">
<simple>imaps://${exchangeProperty.imapUrl}:${exchangeProperty.imapPort}?authenticator=#exchangeAuthenticator&debugMode=true&delete=false&unseen=true&delay=10000&mail.imaps.proxy.host={{proxyHost}}&mail.imaps.proxy.port={{proxyPort}}&mail.imaps.auth.mechanisms=XOAUTH2&searchTerm=#customSearchTerm</simple>
</pollEnrich>
<log message="Route 'mail-route-imap' registered successfully." />
</route>
**EmailConfigProcessor.java**
public class EmailConfigProcessor implements Processor {
@Autowired
private EmailConfigBean emailConfigBean;
@Override
public void process(Exchange exchange) throws Exception {
LOG.info("@#E#@@# EmailConfigProcessor ..... {} ", new Date());
exchange.setProperty("imapUrl", emailConfigBean.getImapUrl()); //this
is fetched clean and logged
exchange.setProperty("imapPort", emailConfigBean.getImapPort()); //this
is fetched clean and logged
}
}
***UPDATE***
<enrich>
<simple>imaps://${exchangeProperty.imapUrl}:${exchangeProperty.imapPort}?authenticator=#exchangeAuthenticator&debugMode=true&delete=false&unseen=true&delay=10000&mail.imaps.proxy.host={{proxyHost}}&mail.imaps.proxy.port={{proxyPort}}&mail.imaps.auth.mechanisms=XOAUTH2&searchTerm=#customSearchTerm</simple>
</enrich>
I tried using the <enrich> tag but that gives an error:
INFO [Camel (camel) thread #1 - timer://loadEmails]
org.apache.camel.spi.CamelLogger: Error occurred: The mail message does
not have any recipients set.
This question is originally posted here
https://stackoverflow.com/questions/79044095/apache-camel-pollenrich-tag-causing-the-timer-uri-to-fail-in-camel-xml-context
Regards.