apache camel - poolEnrich() allways returning one email on aggregate - Stack Overflow

admin2025-04-17  4

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... :(

Share Improve this question asked Feb 1 at 8:21 Kiril NugmanovKiril Nugmanov 11 silver badge1 bronze badge
Add a comment  | 

1 Answer 1

Reset to default -1

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.

转载请注明原文地址:http://anycun.com/QandA/1744834641a88272.html