Have following route in apache camel:
...
...
.pollEnrich()
.simple("""
imap://${exchangeProperty.imapEndpoint}
?delay=0
&initialDelay=0
&additionalJavaMailProperties=#bean:${exchangeProperty.imapAdditionalPropertiesName}
&bridgeErrorHandler=true&disconnect=false
&closeFolder=false
&delete=${exchangeProperty.imapDelete}
&unseen=true
&maxMessagesPerPoll=-1
&username=RAW(${exchangeProperty.imapUsername})
&password=RAW(${exchangeProperty.imapPassword})
""")
.aggregationStrategy(
AggregationStrategies.flexible()
.pick(ExpressionBuilder.messageExpression())
.condition(Objects::nonNull)
.accumulateInCollection(HashSet.class)
.storeInBody()
)
.end()
.process(imapProcessor)
.end();
From processing logs it seen that MailCOnsumer
reading all required emails from IMAP. But for some reason poolEnrich()
allways returns only one email in set.
Note: IMAP server is GMAIL.
How to make it to return all emails (aggregated)
Tried using to(..)
- IMAP is STORE not PROTOCOL.
Tried using enrich()
- same behavior as pollEnrich()
Used all AI - no luck... :(
Have following route in apache camel:
...
...
.pollEnrich()
.simple("""
imap://${exchangeProperty.imapEndpoint}
?delay=0
&initialDelay=0
&additionalJavaMailProperties=#bean:${exchangeProperty.imapAdditionalPropertiesName}
&bridgeErrorHandler=true&disconnect=false
&closeFolder=false
&delete=${exchangeProperty.imapDelete}
&unseen=true
&maxMessagesPerPoll=-1
&username=RAW(${exchangeProperty.imapUsername})
&password=RAW(${exchangeProperty.imapPassword})
""")
.aggregationStrategy(
AggregationStrategies.flexible()
.pick(ExpressionBuilder.messageExpression())
.condition(Objects::nonNull)
.accumulateInCollection(HashSet.class)
.storeInBody()
)
.end()
.process(imapProcessor)
.end();
From processing logs it seen that MailCOnsumer
reading all required emails from IMAP. But for some reason poolEnrich()
allways returns only one email in set.
Note: IMAP server is GMAIL.
How to make it to return all emails (aggregated)
Tried using to(..)
- IMAP is STORE not PROTOCOL.
Tried using enrich()
- same behavior as pollEnrich()
Used all AI - no luck... :(
You can try using enrich()
+ split()
instead of pollEnrich()
or enrich()
alone. Following code may help:
`.enrich()
.simple("imap://${exchangeProperty.imapEndpoint}...")
.aggregationStrategy(AggregationStrategies.groupedBody())
.split(body())
.process(imapProcessor)
.end();`
As pollEnrich()
is incapable of looping over multiple messages.