shashank created CAMEL-27168:
--------------------------------

             Summary: camel-google-mail - the stream consumer marks as read the 
mail of the CamelGoogleMailId header as the route left it, so a route that 
removes the headers consumes the same mail at every poll
                 Key: CAMEL-27168
                 URL: https://issues.apache.org/jira/browse/CAMEL-27168
             Project: Camel
          Issue Type: Bug
          Components: camel-google-mail
            Reporter: shashank
            Assignee: shashank


h3. What happens

With {{markAsRead}} (the default) the {{google-mail-stream}} consumer marks a 
mail as read when its exchange completes, and as unread again when it failed. 
It takes the id of the mail from the {{CamelGoogleMailId}} header at that time. 
A route that removes the headers (for example {{removeHeaders("*")}} before 
calling another system), or replaces the message, marks nothing as read: the 
modify call fails, the exception handler logs a WARN, and with the default 
query {{is:unread}} the same mail is consumed again by every poll (every 10 
seconds by default) for ever. A route that changes the header marks another 
mail as read.

This is the same defect that CAMEL-27015 (#30168) and CAMEL-27064 (#30227) 
fixed in the object storage and queue consumers.

h3. How to reproduce

{{GoogleMailStreamConsumerMarkAsReadTest}} (the {{FakeGmailClientFactory}} of 
the existing stream tests): with {{removeHeaders("*")}} in the route the mail 
is never marked as read and is consumed again by the next polls.

h3. Fix

The consumer takes the id of the mail before the exchange is routed and marks 
that mail. New {{processCommit(Exchange, String, String)}} and 
{{processRollback(Exchange, String, String)}} take the id; the former methods 
are deprecated.

_Filed with Claude Code on behalf of allthingssecurity._



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to